惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Cisco Talos Blog
Cisco Talos Blog
C
Check Point Blog
博客园_首页
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Martin Fowler
Martin Fowler
Recorded Future
Recorded Future
S
Security @ Cisco Blogs
L
LINUX DO - 最新话题
博客园 - 司徒正美
P
Privacy International News Feed
G
Google Developers Blog
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
博客园 - 聂微东
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
K
Kaspersky official blog
I
InfoQ
Y
Y Combinator Blog
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
大猫的无限游戏
大猫的无限游戏
D
Docker
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Microsoft Azure Blog
Microsoft Azure Blog
Spread Privacy
Spread Privacy
量子位
H
Hacker News: Front Page
Simon Willison's Weblog
Simon Willison's Weblog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
SecWiki News
SecWiki News
S
Security Affairs
Latest news
Latest news
人人都是产品经理
人人都是产品经理
C
CERT Recently Published Vulnerability Notes
S
Security Archives - TechRepublic
V
Visual Studio Blog
T
Troy Hunt's Blog
S
Secure Thoughts
F
Fortinet All Blogs
V
V2EX
The Register - Security
The Register - Security
J
Java Code Geeks
MongoDB | Blog
MongoDB | Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - highmayor

在ABAP的SQL语句中写Oracle Hints Screen numbers ABAP 培训笔记 part 7 更改选择屏幕的GUI STATUS---RS_SET_SELSCREEN_STATUS 隐藏标准选择屏幕的执行按钮 SAP秀才-FI速成手册 FOR ALL ENTRIES的效率问题 SAP学习笔记(HR Develepment学习笔记1) 程序间的调用 abap技术问题中文 - highmayor - 博客园 函数组的文件结构 闲说继承 oracle删除重复行 深度理解按位异或运算符 一个容易忽略的陷阱:修改字符串常量的值 - highmayor - 博客园 使用sqlplus copy 命令在两个数据库间转移数据 Oracle数据库 Exp/Imp工具性能调优 通过JDBC操作ORACLE数据库 算法的时间复杂度(计算实例)
oracle中使用SQL递归语句
highmayor · 2010-07-08 · via 博客园 - highmayor

例子:

 pid  id
  a   b  
  a   c    
  a   e  
  b   b1  
  b   b2  
  c   c1  
  e   e1  
  e   e3  
  d   d1  
   
  指定pid=a,选出  
  a   b  
  a   c    
  a   e  
  b   b1  
  b   b2  
  c   c1  
  e   e1  
  e   e3 
SQL语句:select   parent,child   from   test   start   with   pid='a'   
connect   
by   prior   id=pid 

Oracle  SQL的递归查询:
1、表机构
SQL> desc comm_org_subjection
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 ORG_SUBJECTION_ID                         NOT NULL VARCHAR2(32)    子键
 ORG_ID                                    NOT NULL VARCHAR2(32)
 FATHER_ORG_ID                             NOT NULL VARCHAR2(32)         父键
 LOCKED_IF                                 NOT NULL VARCHAR2(1)
 START_DATE                                NOT NULL DATE
 END_DATE                                           DATE
 EDITION_NAMEPLATE                                  NUMBER(8)
 CODE_AFFORD_IF                                     VARCHAR2(1)
 CODE_AFFORD_ORG_ID                        NOT NULL VARCHAR2(32)
 CODING_SHOW_ID                                     NUMBER(8)
 BSFLAG                                             VARCHAR2(1)
 MODIFI_DATE                                        DATE
 CREATOR_ID                                         VARCHAR2(32)
 CREATE_DATE                                        DATE
 CREATOR                                            VARCHAR2(35)


2、递归查找父结点 org_id为C6000000000001下的所有子结点:
select * from comm_org_subjection a
start with a.org_id='C6000000000001'
connect by prior a.org_subjection_id=a.father_org_id


3、递归查找子结点 org_id为C6000000000001下的所有父结点:
select org_id from comm_org_subjection a
start with a.org_id='C6000000000001'
connect by prior a.father_org_id=a.org_subjection_id