标签:11g 日期 通过 cli 详细 cal ons 列表 全表扫描
select * from dept where deptno in(select distinct deptno from emp);
select * from dept where deptno in (select deptno from emp group by deptno having count(deptno)>=1);
select * from dept a where exists (select null from emp b where a.deptno=b.deptno);
select ename from emp where sal>(select sal from emp where ename=‘SMITH‘);
select e.ename,p.ename from emp e,emp p where p.empno(+)=e.mgr; select p.ename,e.ename from emp p left join emp e on e.empno=p.mgr;
Execution Plan ---------------------------------------------------------- Plan hash value: 2341341676 --------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | --------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 14 | 280 | 7 (15)| 00:00:01 | |* 1 | HASH JOIN OUTER | | 14 | 280 | 7 (15)| 00:00:01 | | 2 | TABLE ACCESS FULL| EMP | 14 | 140 | 3 (0)| 00:00:01 | | 3 | TABLE ACCESS FULL| EMP | 14 | 140 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("E"."EMPNO"(+)="P"."MGR") Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 15 consistent gets 0 physical reads 0 redo size 823 bytes sent via SQL*Net to client 523 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 14 rows processed
select e.ename,(select ename from emp p where p.empno=e.mgr)as BoosName from emp e;
Execution Plan ---------------------------------------------------------- Plan hash value: 4000517069 -------------------------------------------------------------------------------- ------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------- ------ | 0 | SELECT STATEMENT | | 14 | 140 | 3 (0)| 00:0 0:01 | | 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 10 | 1 (0)| 00:0 0:01 | |* 2 | INDEX UNIQUE SCAN | PK_EMP | 1 | | 0 (0)| 00:0 0:01 | | 3 | TABLE ACCESS FULL | EMP | 14 | 140 | 3 (0)| 00:0 0:01 | -------------------------------------------------------------------------------- ------ Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("P"."EMPNO"=:B1) Statistics ---------------------------------------------------------- 1 recursive calls 0 db block gets 17 consistent gets 0 physical reads 0 redo size 849 bytes sent via SQL*Net to client 523 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 14 rows processed
a. select p.ename from emp e,emp p where e.empno=p.mgr and p.hiredate<e.hiredate;
select e.ename from emp e where e.hiredate<(select hiredate from emp p where p.empno=e.mgr);
select a.dname,b.ename from dept a,emp b where a.deptno=b.deptno(+);
select a.dname,b.ename from dept a left join emp b on a.deptno=b.deptno
select b.ename,a.dname from dept a,emp b where a.deptno=b.deptno and b.job=‘CLERK‘;
select min(sal)as minsal,job from emp group by job having min(sal)>1500;
select ename from emp where deptno=(select deptno from dept where dname=‘SALES‘);
select ename from emp where sal>(select avg(sal) from emp);
select ename from emp where job=(select job from emp where ename=‘SCOTT‘);
select ename,sal from emp where sal in (select sal from emp where deptno=30);
select ename,sal from emp where sal > (select max(sal) from emp where deptno=30);
select a.deptno,a.dname,a.loc,b.ss from dept a,(select deptno,count(ename) ss from emp group by deptno) b where a.deptno=b.deptno;
select a.ename,b.dname,a.sal from emp a,dept b where a.deptno=b.deptno(+);
select a.ename,b.ename,a.job,b.job,a.deptno,b.deptno from emp a,emp b where a.job=b.job and a.deptno<>b.deptno;
select a.deptno,a.dname,a.loc,nvl(b.ss,0) from dept a, (select deptno,count(ename) ss from emp group by deptno) b where a.deptno=b.deptno(+);
select a.deptno,dname,loc,count(empno) ss from dept a,emp b where a.deptno=b.deptno(+) group by a.deptno,a.dname,a.loc;
select job,min(sal) as minjobsal from emp group by job;
select deptno,min(sal) ss from emp where job=‘MANAGER‘ group by deptno;
select ename,(sal*12+nvl(comm,0)) as nianxin from emp order by nianxin;
select ename,a.tt from (select rownum tt,ename,(sal*12+nvl(comm,0)) as nianxin from emp)a where a.tt=4;
select * from (select ename,sal,rank()over(order by sal desc)as nn from emp) where nn=4;
标签:11g 日期 通过 cli 详细 cal ons 列表 全表扫描
原文地址:https://www.cnblogs.com/kingwwz/p/10759782.html