清理Postgres文本数组

时间:2016-03-07 14:51:13

标签: postgresql

我正在转向使用Postgres和text []作为关键字。我之前使用过csv字符串。结果,我的数据很难看,我有这样的例子。

{Tor," granite"," rock formations"," landscape"," people"," men"," 1920s"," 20th century"," climbing"}

是否有 easy 方法来修剪和清理数据,因此更像是这样。

{Tor,granite,rock formations,landscape,people,men,1920s,20th century,climbing}

1 个答案:

答案 0 :(得分:0)

你可以这样做:

select replace( replace( yourField, '"', '' ), ', ', ',')
  from yourTable

结果将是:

{Tor,granite,rock formations,landscape,people,men,1920s,20th century,climbing}

在此处查看:http://sqlfiddle.com/#!15/ea962/1