目录树
目录树
--创建表
create table TREE
(
TREEID VARCHAR2(10) not null,
LABLE VARCHAR2(50) not null,
PARENTID VARCHAR2(10)
);
--创建主键
alter table TREE add constraint PK_TREE primary key (TREEID);
--创建表内外键
alter table TREE add constraint FK_TREE foreign key (PARENTID)
references TREE (TREEID);
--查询根节点为4及其下的所有子目录的数据
select * from tree
CONNECT BY PRIOR treeid = parentid
START WITH treeid = ‘4’
ORDER BY treeid;