【发布时间】:2016-05-13 11:12:17
【问题描述】:
我使用postgres9.4,并且存在关系“Patients”有类型为jsonb[]的“contact”列,如何将类型jsonb[]转移到jsonb?
以下是记录在案的。
=>select name, contact from "Patients" where contact is not null;
name | contact
--------+-----------------------------------------------------------------------------------------------------
"tom" | {"{\"name\": \"tom\", \"phone\": \"111111\", \"address\": \"shanghai\", \"relation\": \"your_relation\"}"}
我试过如下,contact4是jsonb类型的列
alter table "Patients" alter column contact4 type jsonb using contact4::text::jsonb;
ERROR: invalid input syntax for type json
DETAIL: Expected ":", but found "}".
CONTEXT: JSON data, line 1: ...ress\": \"shanghai\", \"relation\": \"your_relation\"}"}
【问题讨论】:
-
试试
... using contact4[1]