比如查询scott用户下的emp表,将所有职员安装上下属关系列出
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,
level from emp
start with empno=7839
connect by prior empno=mgr
order by level
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,level from emp
start with empno=7839
connect by prior empno=mgr
order
siblings by empno
当改变根节点的时候
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,level from emp
start with empno=
7566
connect by prior empno=mgr
order siblings by empno
结果如下
select EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO,level from emp
start with empno=7369
connect by prior
mgr=empno
会做一反的查询
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28803801/viewspace-772861/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28803801/viewspace-772861/