自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

帶您了解Oracle層次查詢

數(shù)據(jù)庫(kù) Oracle
Oracle數(shù)據(jù)庫(kù)中有很多種的查詢,下文為您介紹的是Oracle層次查詢的方法,如果您對(duì)此方面感興趣的話,不妨一看。

Oracle層次查詢(connect by )是結(jié)構(gòu)化查詢中用到的,下面就為您介紹Oracle層次查詢的基本語(yǔ)法,希望可以讓您對(duì)Oracle層次查詢有更深的認(rèn)識(shí)。

oracle中的select語(yǔ)句可以用START WITH...CONNECT BY PRIOR子句實(shí)現(xiàn)遞歸查詢,connect by 是結(jié)構(gòu)化查詢中用到的,其基本語(yǔ)法是:

select ... from <TableName>
where <Conditional-1>
start with <Conditional-2>
connect by <Conditional-3>
;
<Conditional-1>:過(guò)濾條件,用于對(duì)返回的所有記錄進(jìn)行過(guò)濾。
<Conditional-2>:查詢結(jié)果重起始根結(jié)點(diǎn)的限定條件。
<Conditional-3>:連接條件

數(shù)據(jù)組織結(jié)構(gòu)如下圖:



數(shù)據(jù)庫(kù)表結(jié)構(gòu)如下:

create table t2(
root_id number,
id number,
name varchar(5),
description varchar(10)
);

insert into t2(root_id,id,name,description) values(0,1,'a','aaa');
insert into t2(root_id,id,name,description) values(1,2,'a1','aaa1');
insert into t2(root_id,id,name,description) values(1,3,'a2','aaa2');
insert into t2(root_id,id,name,description) values(0,4,'b','bbb');
insert into t2(root_id,id,name,description) values(4,5,'b1','bbb1');
insert into t2(root_id,id,name,description) values(4,6,'b2','bbb2');

獲取完整樹(shù):
select * from t2 start with root_id = 0 connect by prior id = root_id;


獲取特定子樹(shù):
select * from t2 start with id = 1 connect by prior id = root_id;


select * from t2 start with id = 4 connect by prior id = root_id;



如果connect by prior中的prior被省略,則查詢將不進(jìn)行深層遞歸。
如:

select * from t2 start with root_id = 0 connect by id = root_id;



select * from t2 start with id = 1 connect by id = root_id;
如:

 

 

 

【編輯推薦】

oracle查詢中表的連接順序

oracle查詢用戶所有表的語(yǔ)句

常見(jiàn)的ORACLE數(shù)據(jù)類型介紹

查詢Oracle日志文件的方法

Oracle索引的優(yōu)化設(shè)計(jì)

責(zé)任編輯:段燃 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-10-27 14:27:13

oracle查詢語(yǔ)句日

2010-10-27 14:57:24

Oracle查詢

2010-10-26 11:55:21

Oracle OS備份

2010-10-25 09:39:43

Oracle FBI索

2010-10-25 15:04:39

Oracle文本函數(shù)

2010-10-29 15:37:51

Oracle物理結(jié)構(gòu)

2010-11-15 10:40:58

Oracle啟動(dòng)參數(shù)

2010-11-15 13:20:06

Oracle恢復(fù)結(jié)構(gòu)

2010-10-28 13:20:50

ORACLE reso

2010-11-16 14:59:39

Oracle顯式游標(biāo)

2010-10-25 15:20:23

Oracle數(shù)據(jù)轉(zhuǎn)換函

2010-10-29 10:56:46

ORACLE用戶驗(yàn)證

2010-10-26 11:28:33

ORACLE運(yùn)行方式

2010-10-28 10:19:29

oracle權(quán)限管理

2010-10-29 14:57:12

Oracle歸檔模式

2010-10-27 15:58:01

Oracle臨時(shí)表

2010-10-29 10:04:27

2010-10-25 17:13:08

oracle分組函數(shù)

2010-11-15 15:44:11

Oracle文件系統(tǒng)

2010-11-16 09:55:12

Oracle分區(qū)索引
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)