且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PostgreSQL 9.3:将一列拆分为多个

更新时间:2022-12-11 18:35:32

select cola
      ,split_part(colb, 'to', 1) col1
      ,split_part(colb, 'to', 2) col2 
from t3

从PostgreSQL文档引用:

Quoted from the PostgreSQL Documentation:


split_part(字符串文本,定界符文本,字段int)

split_part(string text, delimiter text, field int)

在定界符上分割字符串并返回给定的字段(计数从
一个)

Split string on delimiter and return the given field (counting from one)