sql语言按功能分为:数据定义语言DDL、数据操纵语言DML、
数据查询语言DQL、数据控制语言DCL

一、数据操纵语言DML
1.insert 新增
语法:insert into <表名> (列名,...) values (值,...);
view dept;
desc dept;
insert into dept (deptno,dname,loc) values (41,'行政部','北京');
insert into dept values (42,'人事部','上海');
insert into dept (deptno) values (43);
--insert into dept (dname) values ('开发部');
insert into dept values (44,'开发1部',null);
insert into dept
select trunc(empno/100),ename,null from emp where job='MANAGER';

2.update 修改
语法:update 表名 set <列名1>=<值1>,... where 条件;
update dept set loc='西安' where deptno=44;
update dept set dname='采购部',loc='成都' where deptno=43;
update dept set loc='深圳' where loc is null;
update dept set (dname,loc)=
(select '大数据开发部','上海' from dual) where deptno=75;
--update dept set dname='采购部';

3.delete 删除
语法:delete from <表名> where 条件;
delete from dept where deptno=44;
--delete from dept;
delete from dept where loc is null;
delete from dept where deptno>=41;

二、数据控制语言DCL
1.commit 提交
insert into dept (deptno,dname,loc) values (41,'行政部','北京');
insert into dept values (42,'人事部','上海');
commit;
2.rollback 回退
delete from dept;
rollback;
update dept set loc='深圳' where loc is null;
rollback;

三、数据查询语言DQL
1.select

四、数据定义语言DDL
1.create
2.drop
3.alter

05-11 20:42