DML:数据操纵语言(Data Manipulation Language, DML)是语言中,负责对数据库对象运行数据访问工作的指令集,以INSERT、UPDATE、DELETE三种指令为核心,分别代表插入、更新与删除,是开发以数据为中心的应用程序必定会使用到的指令,因此有很多开发人员都把加上SQL的SELECT语句的四大指令以“”来称呼。(来源于百度百科)
insert 关键字
作用:往表中插入一条或者多条记录
元祖(tuple )值的插入(一次插入一条记录)
语法1: insert into tablename (column1,column2,···,columnN) values(val1,val2 ,···,valN)
例如:insert into emp (empno,ename,sal,deptno) values(8888,‘雕沙’,0,40);
如果往表中所有的列表都添加数据时,表后面的字段可以不添加,直接写values
例如:insert into emp values (8888,‘雕沙’,‘aaa’,9527,sysdate ,0,null,40);
查询结果式的插入
语法2:insert into tablename sub-query
例如: insert into emp_temp (select * from emp where deptno = 20);
创建一个emp的临时复制表
create table emp_temp sa select * from emp where 1 = 2 ;
注*:当where后面的等式为正确时,则将表完整负责下来;如果等式不完整,则只复制表头。
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
附录:
UPDATE
1 | UPDATE [ 资料表或可更新检视表物件名称] SET 栏 1 = 值 1 , 栏 2 = 值 2 , 栏 3 = 值 3 , ... WHERE [ 指定条件] |
1 | UPDATE myTable SET Col1 = 3 , Col2 = 5 , Col4 = 5 WHERE Col0 = 198273 |
DELETE
1 2 | DELETE FROM [资料表或可更新检视表名称] WHERE [给定条件] DELETE * FROM [资料表或可更新检视表名称] WHERE [给定条件] -- 部份资料库需要加 "*" 才会生效,例如Microsoft Access |
1 | DELETE FROM myTable WHERE col0 = 1918299 |
(注*:附录部分来源百度百科)