DML语言

453 阅读1分钟

DML语言包括

数据操作语言:

插入:insert

修改:update

删除:delete

插入语句

语法

insert into 表名(列名) value (值1,...)

1、插入的值与类型要与列的类型一致或兼容

insertintobeauty(ID,name,sex,birthday,phone number,...) values (13,'tyx','女','1990-04-23','189999')

2、不可以为null的列必须插入值,可以为null的列如何插入值?

#方法1

insert into beauty(id,name,sex...) values (13,'tyx','女','1990-04-23',null)

#方法2 同时省略

3、列的顺序可以调换,但是要同步

4、列和值的个数必须一致

5、可以省略列名,默认所有列,而且列的顺序

法一法二对比

1、方法一支持插入多行,方法二不支持 2、 方法一支持子查询,方法二不支持

二、修改语句

1、修改表记录

语法
update 表名
set 列= 新值
where 筛选条件

2、修改多表的记录
语法:
sq92
update 表1 别名,表2 别名
set 列 = value,...
where 连接条件
and 筛序条件

sq99语法

update 表1 别名
inner|left|right join 表2 别名
on 连接条件
set 列=值。。。
where 筛选条件;

删除语句

方式一 delete

语法

1、单表删除 delete from 表名 where 筛选条件

2、多表的删除【补充】

sq99

delete 表一的别名,表2的别名 from 表一 别名 inner|left|right join 表2 别名 on 连接条件 where s筛选条件

方式二:truncate 语法:truncate table 表名;