首页 > 代码库 > ORACLE 按逗号拆分字符串为多行

ORACLE 按逗号拆分字符串为多行

with t as
 (select 1,2,3,10,11,12 a from dual)
select substr(a,
              decode(level - 1, 0, 0, instr(a, ,, 1, level - 1)) + 1,
              (decode(level,
                      regexp_count(a, ,) + 1,
                      length(a) + 1,
                      instr(a, ,, 1, level))) -
              (decode(level - 1, 0, 0, instr(a, ,, 1, level - 1)) + 1))
  from t
connect by level <= regexp_count(a, ,) + 1;

 

ORACLE 按逗号拆分字符串为多行