由04年下半年数工下午第二题引发的系列实验4--嵌套相关子查询(nested correlated query) 与 查询预处理...

1 nested correlated query

SQL> edit Wrote file afiedt.buf 1 SELECT ename, sal 2 FROM emp e1 3 WHERE sal= ( 4 SELECT MAX(sal) 5 FROM emp e2 6 WHERE e1.deptno=e2.deptno 7* ) SQL> set timing on SQL> / ENAME SAL ---------- ---------- BLAKE 2850 SCOTT 3000 KING 5000 FORD 3000 Elapsed: 00:00:00.03 SQL> spool off

2 查询预处理

SQL> CREATE TABLE temp 2 AS 3 SELECT deptno, MAX(sal) AS max 4 FROM dupEmp 5 GROUP BY deptno 6 / Table created. Elapsed: 00:00:00.15 SQL> edit Wrote file afiedt.buf 1 SELECT ename, sal 2 FROM dupEmp, temp 3* WHERE dupEmp.deptno=temp.deptno AND dupEmp.sal=temp.max SQL> / ENAME SAL ---------- ---------- BLAKE 2850 SCOTT 3000 KING 5000 FORD 3000 Elapsed: 00:00:00.06 SQL> spool off

0.03<0.15+0.06............................

把它解释为数据太少了吧

你可能感兴趣的:(由04年下半年数工下午第二题引发的系列实验4--嵌套相关子查询(nested correlated query) 与 查询预处理...)