Oracle 简单树查询


--oracle针对树型结构的查询
select lpad('-', level, '-') || ename from emp
start with (ename = 'KING')
connect by prior empno = mgr;

查询结果基于emp表中数据以树形结构显示:
LPAD('-',LEVEL,'-')||ENAME
--------------------------------------------------------------------------------
-KING
--JONES
---SCOTT
----ADAMS
---FORD
----SMITH
--BLAKE
---ALLEN
---WARD
---MARTIN
---TURNER
---JAMES
--CLARK
---MILLER

你可能感兴趣的:(Oracle 简单树查询)