数据仓库服务 GAUSSDB(DWS)-JSON/JSONB函数:jsonb_set(target jsonb, path text[], new_value jsonb [, create_missing boolean])

时间:2024-04-18 16:25:05

jsonb_set(target jsonb, path text[], new_value jsonb [, create_missing boolean])

描述:返回target,用path指定的部分被new_value替换,或者如果create_missing为 true(默认值为true)且path指定的项不存在,则添加new_value。与面向路径的运算符一样,path中出现的负整数从JSON数组的末尾开始计数。

返回类型:jsonb

示例:

1
2
3
4
5
SELECT jsonb_set('[{"f1":1,"f2":null},2,null,3]', '{0,f1}','[2,3,4]', false);
                  jsonb_set
---------------------------------------------
 [{"f1": [2, 3, 4], "f2": null}, 2, null, 3]
(1 row)
support.huaweicloud.com/sqlreference-830-dws/dws_06_0356.html
推荐文章