I use postgres9.4
, and there exists relation "Patients" has column "contact" with type jsonb[]
, how to transfer type jsonb[]
to jsonb
?
The following is on record.
=>select name, contact from "Patients" where contact is not null;
name | contact
--------+-----------------------------------------------------------------------------------------------------
"tom" | {"{"name": "tom", "phone": "111111", "address": "shanghai", "relation": "your_relation"}"}
I have tried as the followings, contact4
is column with type 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"}"}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…