将逗号分隔的值拆分为 Oracle 中的列
我返回了 255 个逗号分隔值的值.有没有一种简单的方法可以在没有 255 个 substr 的情况下将它们拆分成列?
I have values being returned with 255 comma separated values. Is there an easy way to split those into columns without having 255 substr?
ROW | VAL
-----------
1 | 1.25, 3.87, 2, ...
2 | 5, 4, 3.3, ....
到
ROW | VAL | VAL | VAL ...
---------------------
1 |1.25 |3.87 | 2 ...
2 | 5 | 4 | 3.3 ...
推荐答案
你可以使用regexp_substr()
:
select regexp_substr(val, '[^,]+', 1, 1) as val1,
regexp_substr(val, '[^,]+', 1, 2) as val2,
regexp_substr(val, '[^,]+', 1, 3) as val3,
. . .
我建议您在 Excel(或其他电子表格)中生成一列 255 个数字,并使用该电子表格生成 SQL 代码.
I would suggest that you generate a column of 255 numbers in Excel (or another spreadsheet), and use the spreadsheet to generate the SQL code.
相关文章