--遍历
select *
from treetest t
start with t.childid=1
connect by prior t.childid=t.parentid;
--上溯
select *
from treetest t
start with t.childid=7
connect by prior t.parentid=t.childid;
--树查询
select lpad(' ',6*(level-1))||t.child,sys_connect_by_path(childid,' '),level,t.child,t.childid,t.parentid
from treetest t
start with t.childid=1
connect by prior t.childid=t.parentid;
select *
from treetest t
start with t.childid=1
connect by prior t.childid=t.parentid;
--上溯
select *
from treetest t
start with t.childid=7
connect by prior t.parentid=t.childid;
--树查询
select lpad(' ',6*(level-1))||t.child,sys_connect_by_path(childid,' '),level,t.child,t.childid,t.parentid
from treetest t
start with t.childid=1
connect by prior t.childid=t.parentid;