当前位置:网站首页>Easy introduction to SQL (1): addition, deletion, modification and simple query
Easy introduction to SQL (1): addition, deletion, modification and simple query
2022-07-06 17:45:00 【Data digger】
The authors introduce
Whale song
E-commerce industry data analyst
Provide data consulting services for head brands
Keen to learn and share
“ DataMan creators Alliance ” member
Write in the pen SQL In series , I suddenly feel a little confused , Because in a sense SQL It's a stranger I'm familiar with . Familiar because I and SQL We met very early , Looking back on the whole process , We have experienced shallow acquaintance , Long forgotten in the Jianghu , Then there was a brief reunion , Then separation , Up to now, I once again fell under her pomegranate skirt .
Strangeness is because , Just like the process mentioned above , Many belong to me and SQL Because of the separation, my memories become light . This feeling is wonderful , But I'm glad that I finally understand SQL Position in my heart .

You may want to ask me , How to determine SQL Position in my heart ? My answer is , Golden Circle thinking principle . Whether it's work or daily life , Rather than asking yourself why , We prefer to be guided by brain inertia , Take action first . And often many things come to the end , You will find that it was wrong from the beginning .
Used to be in school ,SQL It's just a course on the curriculum , Step into society ,SQL It's just a necessary tool for work , I have never thought deeply , Why should I choose SQL?SQL What does it mean to me .
SQL He is a good comrade in arms for data analysis , No, SQL, Maybe we face the database , I can't wait to sigh ;
SQL It's a high-level nonprocedural programming language , Master it , We can have one more mode of thinking ;
SQL It is also the stepping stone and chip for our job search and salary increase , It may help you to take another step .
Now that you know SQL Importance to me , So in order not to feel strange anymore , The next period of time , I'll get to know it again SQL, And record these feelings in written form , Come on ! Start the journey of revisiting ~

01 What is a database ? What is? SQL?
database , As the name suggests, it is a warehouse for storing data , It's like an all inclusive storage box , Only its object is data . In the database , We are more exposed to relational databases , It includes multiple tables and the relationship between them . In the database , Relationship is the matching of data between two tables , For example, foreign keys .
SQL It is a tool for operating database , There are primitive and natural information in the database , And refining and processing these information depends on SQL.
02 How to install the database ?
In the choice of database , Usually preferred Mysql, It has the advantages of fast running speed and low cost . Specific installation , Please refer to the installation courses shared online .
Mysql And its good friends Navicat, They are the relationship between being managed and being managed , The former serves as a database system , The latter is a database management tool . Our daily basic operations on the database are Navicat In the middle of , It is powerful and easy to learn .

03 The creation of a table 、 Delete and update
Under the created database , You can right-click to select 【 new table 】:

Create table , The fields of the table will be set :

See the following for the type selection :

“ No null” If checked, it means that null value is not allowed , If it is not checked, it is allowed to be null .
A table can choose >=1 Column as primary key / Composite primary key , Ensure that each row of the table has identity uniqueness .
Null And empty string (“”) The difference is that empty characters have values and can be operated .
After the field is set , Click on 【 preservation 】, The skeleton of the table has been built , You need to fill in the corresponding data :

The above data is similar to Excel The data entered in the table is the same , You need to input one by one manually .
2. Tables can be deleted : Right click to select the table to delete :

In practice ,【 Delete table 】 Be careful , Delete unrecoverable , Never owe your hand !
3. and Excel equally , The data in the table has been changed , It needs to be updated , You can right-click the table , Update and save directly in the table .
04 Data insertion 、 Delete and update
In addition to adopting similar Excel In addition to data entry , You can also use query statements to insert 、 Delete and update :
Insert into < Table name >(< Name 1>,< Name 2>,…)
Values(< value 1>,< value 2>,…)

When inputting symbols, you can only use English , Remember that once there is an error, first check whether the symbol is in Chinese .
A statement ends , In English semicolon (;) ending , Can't forget .
2. DELETE Statement to delete rows in a table :DELETE FROM The name of the table WHERE Column name = value

3. Update Statement to modify the data in the table :UPDATE The name of the table SET Column name = The new value WHERE Column name = Certain value

05 Simple query
The following covers 3 part :
School The database contains 4 Reports :student、score、course and teacher, Report details and primary key ;
SQL Knowledge point framework : Basic statement 、 notes 、 Operators and fuzzy queries ;
Screenshot of actual operation : Correspond to the knowledge points one by one , Continuously improve from practice .
The following figure shows the current issue SQL The statement involves 4 Reports , Although the form is very small , In fact, the energy is huge , The real business scenario will involve more reports and massive data , The essence of the two is the same , The difference is the amount of data . If you can put 4 The actual operation of the report is smooth , So I'm not afraid to encounter a huge amount of data in the future ~

although SQL Easy to use , But as a database tool , We still have to practice makes perfect . Remember the story of the oil man ? Weng said :“ dedicated , But hand cooked. .” At work , Whether it's Excel、SQL still Python, We all need to practice while laying a solid foundation .

SQL Queries are generally targeted data retrieval , Rarely will you query the whole table , Because the amount of data presented is different from SQL The response speed is proportional , When the amount of data is very large, the response time will be longer , If you really need to see the whole table , It can be used limit Limit the number of rows ;

As In addition to setting the alias of the column , You can also set the alias of the table , Especially when it comes to multi table joins ;

Distinct Remember the placement of , In addition, the use of multiple columns may be ignored ;

Select You can also calculate the value directly ;




Not It's not commonly used , But you can also see in complex sentences , At this time, you should understand the meaning it represents ;

The priority of the operation cannot be mistaken , If it's a little windy , You can put it on the paper first where Write the clause well ;



Fuzzy query is used in many practical business scenarios , It is necessary to clarify what data to extract .


The old saying goes : The fist does not leave the hand , practice singing all the time ,SQL Also practice often !SQLZOO Is a good practice website , It's not important to know , It's good to do it , come on. !
边栏推荐
- EasyCVR授权到期页面无法登录,该如何解决?
- C version selenium operation chrome full screen mode display (F11)
- 中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
- 07个人研发的产品及推广-人力资源信息管理系统
- Automatic operation and maintenance sharp weapon ansible Playbook
- MySQL报错解决
- Based on infragistics Document. Excel export table class
- Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
- Total / statistics function of MySQL
- 分布式不来点网关都说不过去
猜你喜欢
![[reverse intermediate] eager to try](/img/5a/568533850ddfd1c41117da0df50e20.png)
[reverse intermediate] eager to try

05 personal R & D products and promotion - data synchronization tool
![[introduction to MySQL] third, common data types in MySQL](/img/11/66b4908ed8f253d599942f35bde96a.png)
[introduction to MySQL] third, common data types in MySQL

Kali2021 installation and basic configuration

yarn : 无法加载文件 D:\ProgramFiles\nodejs\yarn.ps1,因为在此系统上禁止运行脚本

Deploy flask project based on LNMP

中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障

FlutterWeb瀏覽器刷新後無法回退的解决方案

TCP连接不止用TCP协议沟通

Unity particle special effects series - treasure chest of shining stars
随机推荐
远程代码执行渗透测试——B模块测试
C#WinForm中的dataGridView滚动条定位
The art of Engineering (1): try to package things that do not need to be exposed
About selenium starting Chrome browser flash back
sql语句优化,order by desc速度优化
全网最全tcpdump和Wireshark抓包实践
Reppoints: advanced order of deformable convolution
BearPi-HM_ Nano development board "flower protector" case
connection reset by peer
Spark accumulator and broadcast variables and beginners of sparksql
【MySQL入门】第一话 · 初入“数据库”大陆
Guidelines for preparing for the 2022 soft exam information security engineer exam
Essai de pénétration du Code à distance - essai du module b
Deploy flask project based on LNMP
Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
Flink parsing (IV): recovery mechanism
应用服务配置器(定时,数据库备份,文件备份,异地备份)
Flink parsing (VII): time window
03 products and promotion developed by individuals - plan service configurator v3.0
[reverse intermediate] eager to try