将字符串中的每个字符转换为一行

时间:2014-05-12 11:43:56

标签: sql oracle oracle11g sqlplus

我有一个包含字符串的字符串,例如' 12345' (没有分隔符或空格)我想将此列拆分为每个字符的行:

自:

 COLUMN
 ------------------
 12345

要:

 COLUMN
 ------------------
 1
 2
 3
 4
 5

这应该在单个选择中工作,以便我可以像这样使用它:

......和SOMECOLUMN不相似( ......选择......

1 个答案:

答案 0 :(得分:3)

with temp as (select '12456' as str from dual)
select substr(str,level,1)
from temp
connect by level <= length(str);

结果:

1
2
4
5
6
相关问题