关于字符串转行 rt,上次在各位大侠的热情帮助下解决了多行转化成字符串的问题,这次又碰到麻烦了 id
1,2,4,5,6,8
怎么把它转化成 id details 1 1 2 2 3 4 4 5 5 6 6 8
简单的说就是怎么把字符串拆成多行,csdn是个神奇的地方,还请各位大侠帮帮忙,指点迷津
------解决方案-------------------- with tt as(select '1,2,4,5,6,8' a from dual)
select level,substr(a,instr(','||a,',',1,level),instr(a||',',',',1,level)-instr(','||a,',',1,level))a from tt connect by level<=length(a)-length(replace(a,','))+1
------解决方案-------------------- SQL> with tt as(select '1,2,4,5,6,8' a from dual) 2 select rownum id, substr(a,rownum*2-1,1) details from tt 3 connect by rownum<=(length(a)+1)/2 4 ;