1

Classification of SQL

  • DDL (Data Definition Language) includes CREATE, DROP, ALTER, RENAME, TRUNCATE and other keywords used to create, delete, and modify the structure of databases and data tables.
  • DML (Data Manipulation Language) includes INSERT, DELETE, UPDATE, SELECT and other keywords used to add, delete, update, query (sometimes independent as DQL) database records.
  • DCL (Data Contril Language) includes GRANT, REVOKE, COMMIT, ROLLBACK, SAVEPOINT and other keywords used to define security levels and access rights.

Rules and Specifications of SQL

basic rules

  • SQL can be written in one line or multiple lines. For readability, it is recommended to write clauses in separate lines and introduce necessary indentation.
  • Every SQL statement ends with an English semicolon ';' or \g, \G.
  • Keywords cannot be abbreviated and cannot be divided into lines
  • Single quotes can be used for string and date data, and double quotes should be used for other column names. It is not recommended to omit as.

case specification

  • Database name, table name, table alias, variable name, field alias are all lowercase
  • SQL keywords, function names, and bind variables are capitalized

Annotation Specification

  • MySQL-specific single-line comment method: #Comment text
  • Single-line comment method: -- comment text -- remember two -- there must be a space after
  • Multi-line comment method: / comment text /

LiberHome
409 声望1.1k 粉丝

有问题 欢迎发邮件 📩 liberhome@163.com