开发工具与关键技术:PLSQL Developer
撰写时间:2019年4月15
DML,全称:Date Manipulation Language,译为数据操纵语言,可在一下条件执行:
- 向表中插入数据;
- 修改现存数据;
- 删除线存数据;
一.插入数据:
Insert 语句语法:
Insert into biaoming values(…)
Insert into asd values(1,'测试');
已向asd 表插入一条数据,这种方法一次能能插入一条数据;
Insert into asd (id,department) values(2, '08-08');
注:字符和日期型数据应包含在单引号中
- 为每一列添加一个新值
- 在 INSERT 子句中随意列出列名和他们的值;
- 向表中插入空值时:在列名表中省略该列的值 或 在VALUES 子句中指定空值
从其它表中拷贝数据语法:
Insert into biaoming select * from biaoming1
insert into eml select * from employees
成功复制employees 表中的108 条数据到 eml 表中
二.更新数据:
UPDATE 语句语法:
Update biaoming set newshuju where tiaojian;
update eml set salary=99999 where last_name = 'King';
已有两条数据被更新;
注:1.可以一次更新多条数据
2.可以使用 WHERE 子句指定需要更新的数据
3.如果省略 WHERE 子句,则表中的所有数据都将被更新
在UPDATE语句中使用子查询:
update eml set salary=8888 where last_name in (select last_name from eml where salary in 2500)
三.删除数据:
delete语句语法:
delete from biaoming where tiaojian
delete from eml where department_id in 20
已删除两条数据,可以回滚;
注:1.可以使用 WHERE 子句指定需要删除的数据
2.如果省略 WHERE 子句,则表中的全部数据将被删除
在delete语句中使用子查询:
delete from eml where department_id in (select department_id from employees where salary in 2500)
已删除51条数据,可以回滚