Universal grammar
An SQL statement can be written as a single line or multiple lines, ending with a semicolon.
Case-insensitive, but uppercase keywords are recommended.
Note: single line comment:-comment on the content (space must be added after it) (you can also use # to comment on the content under MySQL)
Multi-line comments:/* comments */
SQL classification
DDL (Data Definition Language): A data definition language used to define database objects: databases, tables, columns, etc.
DML (Data Manipulation Language) Data Manipulation Language is used to add, delete and modify the data of tables in the database.
DQL (Data Query Language) The data query language is used to query the records (data) of tables in the database.
DCL (Data Control Language) is a data control language, which is used to define access rights and security levels of databases and create users.
Query all databases
Create database:
Delete database
Use database
After the database is created, in order to create tables in the database, you must first make clear which database you are operating in, and then you need to use the database.
View the currently used database.
Operation table is to add (create), delete (retrieve), update and delete tables.
Query all table names under the current database.
Query table structure
Create table
MySQL supports many types and can be divided into three categories:
Delete table
When deleting a table, judge whether the table exists.
Modify table name
Add column
Modify data type
Modify column names and data types
Delete column
Add (insert) and delete (update) data.
Add data to the specified column
Add data to all columns
Batch add data
Modify table data
Deleted data