DML语言
数据操作语言
- 插入:insert
- 修改:update
- 删除:delete
插入:
方式一
/*表名
列名
新值
inset into table(列名,.....)
values (值1,....)
注意:支持多行插入
inset into table(列名,.....)
values (值1,....),(值2,....)....
支持子查询
inset into table(列名,.....)
select 值1,,....
*/
- 插入的值得类型与列的类型一致
- 可以为NULL的列:
- 值输入null
- 不输入内容
- 列的顺序可以调换,但需一一对应
- 列数和值得数量必须匹配
- 省略列名,默认所有列,且顺序与表中顺序对应
方式二:
insert into 表名
set 列名=值,....
修改语句
修改单表记录
语法:
update 表名
set 列 = 新值,列2 = 新值...
where 筛选条件;
修改多表记录
语法:
update 表1 别名
连接类型 表2 别名
on 连接条件
set 列 = 新值,列2 = 新值...
where 筛选条件;
删除语句
方式一:delete
delete from 表名
where 筛选条件;
方式二:truncat(删除整表)
truncate table 表名;