oracle 遞迴查詢,向上和向下遍歷

2021-08-09 06:08:39 字數 918 閱讀 2824

--查詢全部資源資訊 

select * from urm_class_info 

--向上遍歷樹,找到路徑直到根節點,指定的是parentid 

select distinct classid,parentid,name 

from urm_class_info 

start with parentid = 'cmdb0000000000000017' 

connect by prior parentid = classid 

--向上遍歷樹,找到路徑直到根節點,指定的是classid,和下面的主要區別就是parentid和classid的位置 

select classid,parentid,name 

from urm_class_info 

start with classid = 'cmdb0000000000000401' 

connect by prior parentid = classid 

--向下遍歷整棵樹,可以指定classid,來遍歷指定節點的樹 

select classid,parentid,name 

from urm_class_info 

start with classid = 'cmdb0000000000000017' 

connect by prior classid = parentid 

--向下遍歷整棵樹,可以指定parentid,來遍歷指定parentid節點的樹,不包含parentid 

select classid,parentid,name 

from urm_class_info 

start with parentid = 'cmdb0000000000000017' 

connect by prior classid = parentid 

oracle 遞迴查詢,向上和向下遍歷

以查詢系統功能在選單那個目錄下為例 系統選單表 sys menus,系統功能表 sys func 查詢全部資源資訊 select from sys menus 向上遍歷樹,找到路徑直到根節點,指定的是f parent 向上遍歷樹,找到路徑直到根節點,指定的是f menu id,和下面的主要區別就是f...

Oracle 向上遞迴 向下遞迴

向上遞迴 select distinct orgguid,dtb orgguid,orgname from dtba organization a start with orgguid 2117bc0897e543168fd9702216165c77 connect by prior dtb org...

Oracle 向上遞迴 向下遞迴

向上遞迴 select distinct orgguid,dtb orgguid,orgname from dtba organization a start with orgguid 2117bc0897e543168fd9702216165c77 connect by prior dtb org...