需要帮助
ACTUAL TABLE
COL1 COL2
A 1,2,3,4
我需要转换
COL1 COL2
A 1
A 2
A 3
A 4
答案 0 :(得分:1)
可能的行数很大!!哎呀..这可能是一个糟糕的方法。
SELECT col1,REGEXP_SUBSTR (col2,,'[^,]+',1,LEVEL) txt
FROM my_table
CONNECT BY REGEXP_SUBSTR (col2,'[^,]+',1,LEVEL) IS NOT NULL
AND PRIOR col2 = col2
AND PRIOR sys_guid() IS NOT NULL;
另一个版本FRom Here
SELECT col1, REGEXP_SUBSTR(t1.col2, '([^,])+', 1, t2.COLUMN_VALUE)
FROM my_table t1 CROSS JOIN
TABLE
(
CAST
(
MULTISET
(
SELECT LEVEL
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT(t1.colval, '([^,])+')
)
AS SYS.odciNumberList
)
) t2;