http://blog.sina.com.cn/s/blog_569eee6401009ifs.html 创建示例表: CREATE TABLE TBL_TEST ( ID NUMBER, NAME VARCHAR2(100 BYTE), PID NUMBER DEFAULT 0 );从Root往树末梢递归 select * from TBL_TEST start with id=1 connect by prior id = pid order by pid
从末梢往树ROOT递归 select * from TBL_TEST start with id=5 connect by prior pid = id order by id
connect by 指定遍历的递归方式
创建示例表:
CREATE TABLE TBL_TEST
(
ID NUMBER,
NAME VARCHAR2(100 BYTE),
PID NUMBER DEFAULT 0
);从Root往树末梢递归
select * from TBL_TEST
start with id=1
connect by prior id = pid
order by pid
从末梢往树ROOT递归
select * from TBL_TEST
start with id=5
connect by prior pid = id
order by id