oracle遍歷樹結構

-- Create table
create table DG
(
  ID    NUMBER,
  SUBID NUMBER
)
tablespace KELY
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64
    minextents 1
    maxextents unlimited
  );

select *
  from dg
   start with id = 1
connect by prior id = subid;

--intersect  --交集
--select * from dg connect by prior id = subid start with id = 4;

select *
  from dg
 start with ID = 4
connect by prior SUBID = ID;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章