层次查询
SQL> --层次查询 SQL> select level,empno,ename,mgr 2 from emp 3 connect by prior empno=mgr 4 start with mgr is null 5 order by 1; LEVEL EMPNO ENAME MGR ---------- ---------- ---------- ---------- 1 7839 KING 2 7566 JONES 7839 2 7698 BLAKE 7839 2 7782 CLARK 7839 3 7902 FORD 7566 3 7521 WARD 7698 3 7900 JAMES 7698 3 7934 MILLER 7782 3 7499 ALLEN 7698 3 7788 SCOTT 7566 3 7654 MARTIN 7698 LEVEL EMPNO ENAME MGR ---------- ---------- ---------- ---------- 3 7844 TURNER 7698 4 7876 ADAMS 7788 4 7369 SMITH 7902 已选择 14 行。
纸上学来终觉浅,觉知此事需躬行