使用PostgreSQL9.3,我可以对JSON数据类型的特定字段执行SELECT操作,但是如何使用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...https://stackoverflow.com/questions/18209625
复制相似问题