Type of SQL
Ddl/dml/dql/dcl
Data definition Language (DDL): CREATE, DROP, ALTER
Used to define and manage data Objects (libraries, tables, indexes, views), including databases, data tables, and so on. For example: CREATE, DROP, Alter, and so on.
Data manipulation statements (DML): and data records in tables
Used for data that is more contained in database objects, such as INSERT, UPDATE, DELETE statements.
1. Inserting data
INSERT into table name ([Field list]) VALUES (Value list), (Value List 2), (Value List 3)
Characteristics:
- If the field list is not given after the table name, the value list must list the values of all fields and must be inserted in the default order in the table
- No single or double quotation marks are added to all fields that require the name of the Write field, but all values are suggested to be used as characters
- When inserting data, it is best to give the field list, and the value should correspond to the field list, not in the order of the fields in the table
For example:
INSERT Into CATS (pid,name) VALUES (' 2 ', ' J2SC '), (' 2 ', ' J2MC '), (' 2 ', ' EE '), (' 3 ', ' thinkphp ');
2. Modify/Update data
UPDATE table name SET field = ' Value ' [, field 2 = ' value 2 ',...] A condition is a condition that determines the record to be changed.
Specify a lot of bars
For example:
3. Delete data
DELETE from table name [condition]
The condition is: where ...
Data Query Language (DQL)
Used to query the data contained in a database object, it is able to query data of different complexity such as single table query, connection query, nested query, and collection query, and return the data to the client. For example: SELECT statement. (60%)
Data Control statement (DCL)
is the language used to manage the database, including administrative permissions and data changes. Example: Grant/revoke/commit/rollback and other statements
MySQL Learning notes (2/2)