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

时间:2024-09-05 10:32:36

jsonb_insert(target jsonb, path text[], new_value jsonb [, insert_after boolean])

描述:返回target,并插入new_value。如果path指定的target部分位于JSONB数组中,则new_value将在目标之前或insert_after为true(默认值为false)之后插入。如果在JSONB对象中由path指定的target部分,则仅当target不存在时才插入new_value。与面向路径的运算符一样,path中出现的负整数从JSON数组的末尾开始计数。

返回类型:jsonb

示例:

1
2
3
4
5
SELECT jsonb_insert('{"a": [0,1,2]}', '{a, 1}', '"new_value"');
         jsonb_insert
-------------------------------
 {"a": [0, "new_value", 1, 2]}
(1 row)
support.huaweicloud.com/sqlreference-dws/dws_06_0356.html
推荐文章