国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
oracle遞歸查詢
對于oracle進行簡單樹查詢(遞歸查詢)
DEPTID PAREDEPTID NAME
NUMBER NUMBER CHAR (40 Byte)
部門id 父部門id(所屬部門id) 部門名稱


通過子節(jié)點向根節(jié)點追朔.

Sql代碼
select * from persons.dept start with deptid=76 connect by prior paredeptid=deptid  

select * from persons.dept start with deptid=76 connect by prior paredeptid=deptid 

通過根節(jié)點遍歷子節(jié)點.

Sql代碼
select * from persons.dept start with paredeptid=0 connect by prior deptid=paredeptid  

select * from persons.dept start with paredeptid=0 connect by prior deptid=paredeptid 

可通過level 關(guān)鍵字查詢所在層次.

Sql代碼
select a.*,level from persons.dept a start with paredeptid=0 connect by prior deptid=paredeptid  

select a.*,level from persons.dept a start with paredeptid=0 connect by prior deptid=paredeptid 

再次復(fù)習一下:start with ...connect by 的用法, start with 后面所跟的就是就是遞歸的種子。

遞歸的種子也就是遞歸開始的地方 connect by 后面的"prior" 如果缺?。簞t只能查詢到符合條件的起始行,并不進行遞歸查詢;

connect by prior 后面所放的字段是有關(guān)系的,它指明了查詢的方向。

練習: 通過子節(jié)點獲得頂節(jié)點

Sql代碼
select FIRST_VALUE(deptid) OVER (ORDER BY LEVEL DESC ROWS UNBOUNDED PRECEDING) AS firstdeptid from persons.dept start with deptid=76 connect by prior paredeptid=deptid 
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
SqlServer 中 類似于Oracle里面的遞歸查詢方法,connect by prior ,start with。
ORACLE函數(shù)sys
Oracle遞歸查詢(start with…connect by prior)
Oracle遞歸查詢
Oracle中遞歸查詢(START WITH……CONNECT BY……)
Connect By、Level、Start With的使用
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服