|
level:把一个字符串按某一分隔符分隔后,变为数据列,即把字符串行变为列
示例1:有规则的字符串
- with t as
- (select 'a;b;c;d;e' as str from dual)
- select level, t.str, substr(t.str, 2 * (level - 1) + 1, 1) as str_signle
- from t
- connect by level <= length(t.str) - length(replace(t.str, ';', '')) + 1;
复制代码 效果图:
示例2:无规则的字符串
- with t as
- (select 'i;am;a;test;hahahhah' as str from dual)
- select level, str, regexp_substr(t.str, '[^;]+', 1, level) str_single
- from t
- connect by level <= length(t.str) - length(replace(t.str, ';', '')) + 1;
复制代码 效果图:
|
|