DML language
1. Insert
insert into 表名(列名1,...)
values (值1,...)
The inserted value type must be consistent or compatible with the column type.
The column that cannot be null must be inserted into the value.
The number of columns and the number of values must be the same.
Column names can be omitted, all columns are defaulted, and the order of the columns is consistent with the order of the columns in the table
insert into 表名
set 列名=值,...
2. Modification
Modification list:
update 表名
set 列=新值,...
where 筛选条件;
Modify multiple tables:
update 表1 别名
inner|left|right| 表2 别名
on 连接条件
set 列=值,...
where 筛选条件
3. Delete
Delete the entire line:
delete from 表名 where 筛选条件
Delete the entire table:
truncate table 表名
Multi-table deletion:
delete 表1 别名,表2 别名
from 表1的别名,表2的别名
inner|left|right| 表2 别名
on 连接条件
where 筛选条件
delete and truncate comparison:
1. delete can add where conditions, truncate can not add
2. truncate delete more efficient
3. If there are self-growth columns in the table to be deleted, if you use delete to delete and then insert data, the self-growth columns will be broken o'clock; and after truncate delete, and then insert the data, since the value of the growth column from the beginning
4.truncate no return value delete, delete delete the return value
can not be rolled back after 5.truncate delete, delete delete can be rolled back