oracle查询递归表节点

前端之家收集整理的这篇文章主要介绍了oracle查询递归表节点前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转载自:http://lizhen3708693.iteye.com/blog/1631184

查询全部资源信息
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,name
from urm_class_info
start with classid = ‘cmdb0000000000000401’
connect by prior parentid = classid
–向下遍历整棵树,可以指定classid,来遍历指定节点的树
select classid,name
from urm_class_info
start with classid = ‘cmdb0000000000000017’
connect by prior classid = parentid
–向下遍历整棵树,可以指定parentid,来遍历指定parentid节点的树,不包含parentid
select classid,name
from urm_class_info
start with parentid = ‘cmdb0000000000000017’
connect by prior classid = parentid

相关分页关联查询示例:

select * from ( select t.*,rownum rn from ( select a.*,b.name as classname from T_DBSET a left join t_dbclass b on a.classid=b.id where a.classId in( select id from t_dbclass start with id = 'fddbfb7b898544aab4dd9840b8cc46bc' connect by prior id = fartherid ) ) t ) where rn >0 and rn<=30
原文链接:https://www.f2er.com/oracle/209901.html

猜你在找的Oracle相关文章