将逗号分隔的值拆分为 Oracle 中的列 [英] Split comma separated values to columns in Oracle

查看:37
本文介绍了将逗号分隔的值拆分为 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.

这篇关于将逗号分隔的值拆分为 Oracle 中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆