表Test有两列 
  id
  parent_idparent_id为嵌套表结构,对应上级节点ID例: id  parent_id
     1  
     2      1
     3      1
     4     2,3表示如下
  1.parent_id=null 根节点
  2.parent_id=1    一个父节点
  3.parent_id=1    一个父节点
  4.parent_id=2,3  两个父节点
实现语句如下:drop table test;create or replace type number_ntabtyp is table of number;create table TEST
(
 ID        NUMBER,
 PARENT_ID NUMBER_NTABTYP
)
nested table PARENT_ID store as NTAB_TEST;insert into test
  select id, parent_id
    from (select id,
                 decode(id,
                        1,
                        null,
                        4,
                        number_ntabtyp(id - 2, id - 1),
                        number_ntabtyp(id - 1)) parent_id
            from (select level id from dual connect by level <= 10));commit;--查询效果如下
select level, sys_connect_by_path(id, '>')
  from test
connect by regexp_like((select wm_concat(column_value) from table(parent_id)),
                       '^([^,]+,)*' || prior to_char(id) || '(,[^,]+)*$')
 start with id = 1;
求更高效的查询方式