Oracle DML SQL语句总结

desc dept;--描述这张表
DML = Data Manipulation Language 数据操纵语言
insert into dept values (50, 'game', 'bj');
rollback;
备份表
create table emp2 as select * from emp;
create table dept2 as select * from dept;
create table salgrade2 as select * from salgrade;
create table emp3 as select * from emp;

insert

insert into dept2 values (50, 'game', 'bj');
insert into dept2 (deptno,dname) values (60, 'game2');
insert into dept2 select * from dept;--结构一样

rownum

select empno,ename from emp;
select empno,ename from emp where rownum < 5;
select empno,ename from emp where rownum <= 5;


--ronum只能与<和<=连用,不能与>和=连用
select empno,ename from emp where rownum > 10;
select empno,ename from emp where rownum = 10;

select rownum r,ename from emp;
select ename from (select rownum r,ename from emp) where r > 10;

select ename,sal from emp order by sal desc;
select ename,sal from emp where rownum <=5 order by sal desc;

--求薪水最高的前5名雇员
select ename,sal from
  (select ename,sal from emp order by sal desc) where rownum <=5;

--薪水最高的第6到10名雇员(重点掌握),效率高BBS
select ename,sal from 
  (
    select ename,sal,rownum r from 
      (select ename,sal from emp order by sal desc)
)
where r >= 6 and r <=10;

update

update emp2 set sal = sal*2,ename=ename||'-' where deptno = 10;
select ename,sal from emp2 where deptno = 10;

delete

delete from emp2;
delete from dept2 where deptno < 25;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值