postgresql 函数 regexp_split_to_table、regexp_split_to_array

版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/ctypyb2002/article/details/84581697

这两个函数都是用来将字符串转换成格式化数据,一个是转换成结果集,一个是转换成数组。

regexp_split_to_table 函数


select regexp_split_to_table(coalesce('/home/postgres/pg_basebackup.sh',''),E'\/') 
; 

 regexp_split_to_table 
-----------------------
 
 home
 postgres
 pg_basebackup.sh
(4 rows)

regexp_split_to_array 函数

select regexp_split_to_table(coalesce('/home/postgres/pg_basebackup.sh',''),E'\/') 
;  

        regexp_split_to_array        
-------------------------------------
 {"",home,postgres,pg_basebackup.sh}
(1 row)

Time: 0.315 ms

参考:
http://postgres.cn/docs/9.6/functions-string.html
http://postgres.cn/docs/9.6/functions-matching.html#FUNCTIONS-POSIX-REGEXP

猜你喜欢

转载自blog.csdn.net/ctypyb2002/article/details/84581697