oracle 创建自增列 及oracle表的字段的子节点的查询

首先创建序列:

create sequence 序列名 start with 1 increment by 1 nomaxvalue nocycle

其次创建触发器:

create or replace trigger 触发器名 before insert on 表名称 for each row
begin
select  序列名.nextval  into:new.表的列名  from dual;
end;

查询一个具有父列的表(表1)

id     fid

1       0

2       1

3       1

4       2

5      3 

查询fid=0下的所有子列

select    id    from  表1    START WITH FID ='0' CONNECT BY PRIOR   id= fid  

查询结果如下:

id

2

4

3

5

原文地址:https://www.cnblogs.com/umlzhang/p/1732721.html