使用postgresql 9.3,我可以使用SELECT
选择JSON数据类型的特定字段,但如何使用UPDATE
修改它们?在postgresql文档或任何在线资源中,我都找不到任何关于此的示例。我已经尝试了显而易见的方法:
postgres=# create table test (data json);
CREATE TABLE
postgres=# insert into test (data) values ('{"a":1,"b":2}');
INSERT 0 1
postgres=# select data->'a' from test where data->>'b' = '2';
?column?
----------
1
(1 row)
postgres=# update test set data->'a' = to_json(5) where data->>'b' = '2';
ERROR: syntax error at or near "->"
LINE 1: update test set data->'a' = to_json(5) where data->>'b' = '2...