常用的两个字符串分割函数:regexp_split_to_table、regexp_split_to_array,具体作用其实显而易见,一个是分割成表,一个是数组。
示例:
--
select regexp_split_to_table('1,2',',');
-- regexp_split_to_table
-- 1
-- 2
-- 如果不指定分割符(或者说是空字符串),分割每个字符
select regexp_split_to_table('1,2','');
-- regexp_split_to_table
-- 1
-- ,
-- 2
select regexp_split_to_array('1,2',',');
-- regexp_split_to_array
-- {1,2}
select regexp_split_to_array('1,2','');
-- regexp_split_to_array
-- {1,",",2}
select (regexp_split_to_array('1,2',''))[2];
-- regexp_split_to_array
-- ,