1. What is SQL?
Structured Query Language: Structured Query Language
actually defines the rules for operating all relational databases. Each way of database operation is different, which is called "dialect".
2.SQL general syntax
-
SQL statements can be written in single or multiple lines, ending with a semicolon.
-
Spaces and indentation can be used to enhance the readability of statements.
-
The SQL statements of the MySQL database are not case sensitive, and it is recommended to use uppercase for keywords.
-
Three kinds of comments
* Single-line comment: – Comment content or # Comment content (mysql-specific)
* Multi-line comment: /* Comment*/
Example:
Note: There must be a space between-and the comment statement, #可有可无
3. SQL classification
1) DDL (Data Definition Language) data definition language is
used to define database objects: databases, tables, columns, etc. Keywords: create, drop, alter, etc.
2) DML (Data Manipulation Language) data manipulation language is
used to add, delete, and modify the data in the table in the database. Keywords: insert, delete, update, etc.
3) DQL (Data Query Language) data query language is
used to query the records (data) of the table in the database. Keywords: select, where, etc.
4) DCL (Data Control Language) data control language (understand) is
used to define database access rights and security levels, and create users. Keywords: GRANT, REVOKE, etc.
As shown in the figure: