postgresql jsonb查询更新问题,jsonb_insert函数
基于pg 9.4,有如下表,data是jsonb类型。
CREATE TABLE users (
id serial PRIMARY KEY,
data jsonb
);
INSERT INTO "public"."users" VALUES ('1', '{"Address": {"City": "Skopje", "Country": "Macedonia"}, "LastName": "Doe", "FirstName": "John"}');
然后根据官方文档https://www.postgresql.org/docs/current/functions-json.html的jsonb_insert函数,
,我想要在data字段里再插入一个key,value,执行如下sql:
UPDATE users
SET DATA = jsonb_set (DATA, '{Age}', '"30"', TRUE)
WHERE
ID = 1;
报错:
[Err] ERROR: function jsonb_set(jsonb, unknown, unknown, boolean) does not exist
LINE 2: SET DATA = jsonb_set (DATA, '{Age}', '"30"', TRUE)
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
希望各位回答一下。