--表结构和测试数据
create table T_RBAC_RES ( ID NUMBER not null, PARENTLD NUMBER, NAME VARCHAR2(20) not null ) tablespace USERS pctfree 10 initrans 1 maxtrans 255 storage ( initial 64K minextents 1 maxextents unlimited );
insert into T_RBAC_RES (ID, PARENTLD, NAME) values (1, 2, '熊小小小敏'); insert into T_RBAC_RES (ID, PARENTLD, NAME) values (2, 3, '熊小小敏'); insert into T_RBAC_RES (ID, PARENTLD, NAME) values (3, 4, '熊小敏'); insert into T_RBAC_RES (ID, PARENTLD, NAME) values (4, 5, '熊敏'); insert into T_RBAC_RES (ID, PARENTLD, NAME) values (5, 6, '熊荣华'); insert into T_RBAC_RES (ID, PARENTLD, NAME) values (6, null, '熊荣华'); commit;
--sql语句
select id,name,parentld from t_rbac_res start with id = 6 connect by parentld = prior id;