oracle 將一個字符串分割成多行

第一種方法:select

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 bbco

第二種connect

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

相關文章
相關標籤/搜索