oracle 将一个字符串分割成多行

第一种方法:

select substr(t,1,instr(t,',',1)-1) from (
select substr(s,instr(s,',',1,rownum)+1)||',' as t,rownum as d ,instr(s,',',1,rownum)+1 from (
select ',tt,aa,bb'  as s from dual
)connect by instr(s,',','1',rownum)>1)

查询结果:

    SUBSTR(T,1,INSTR(T,',',1)-1)
1 tt
2 aa
3 bb

第二种

select substr(t,1,instr(t,',',1)-1)   from (
select substr(s,instr(s,',',1,rownum)+1) as t,rownum as d ,instr(s,',',1,rownum)+1 from (
select ',tt,aa,bb,'  as s from dual
)connect by instr(s,',','1',rownum)>1)
 where t is not null

 

posted @ 2015-04-02 20:14  so...  阅读(3177)  评论(0编辑  收藏  举报