Oracle Database 分割定界字符串
本文向大家介绍Oracle Database 分割定界字符串,包括了Oracle Database 分割定界字符串的使用技巧和注意事项,需要的朋友参考一下
示例
样本数据:
CREATE TABLE table_name ( value VARCHAR2(50) ); INSERT INTO table_name ( value ) VALUES ( 'A,B,C,D,E' );
查询:
WITH items ( list, item, lvl ) AS ( SELECT value, REGEXP_SUBSTR( value, '[^,]+', 1, 1 ), 1 FROM table_name UNION ALL SELECT value, REGEXP_SUBSTR( value, '[^,]+', 1, lvl + 1 ), lvl + 1 FROM items WHERE lvl < REGEXP_COUNT( value, '[^,]+' ) ) SELECT * FROM items;
输出:
LIST ITEM LVL --------- ---- --- A,B,C,D,E A 1 A,B,C,D,E B 2 A,B,C,D,E C 3 A,B,C,D,E D 4 A,B,C,D,E E 5