日期:2014-05-17 浏览次数:20807 次
with t1 as
(
select 'a,b,c' c1 from dual
)
select distinct regexp_substr(c1, '[^,]+',1,level) c1
from t1
connect by level <= length(c1) - length(replace(c1,',','')) + 1
c1
----------------------------
1 a
2 b
3 c
select a,b,regexp_substr(c,'[^,]+',1,level,'i') c from
t1
connect by level <= length(c) - length(replace(c,',','')) + 1
with t1 as
(
select 1 id,'a,b,c' c1 from dual union all
select 2,'d,e,' c1 from dual
)
select distinct id,
regexp_substr(decode(substr(c1,-1),',',substr(c1,1,length(c1)-1),c1), '[^,]+',1,level) c1
from t1
connect by level <= length(decode(substr(c1,-1),',',substr(c1,1,length(c1)-1),c1)) - length(replace(c1,',','')) + 1
id c1
------------------------
1 1 a
2 1 c
3 1 b
4 2 d
5 2 e