-- 向 json 字符串 other_info 中追加数据
WITH t AS (
SELECT id
, "replace"(other_info
, substr(other_info, length(other_info) - 10, 11)
, substr(other_info, length(other_info) - 10, 10)||',"newKey":"newValue"}'
) as new_other_info
from tableName
WHERE position('newKey' in other_info)<=0
)
UPDATE tableName a
SET other_info = t.new_other_info
FROM t
WHERE a.id = t.id
Postgresql 9.3.0 向 JSON 字段追加数据
最新推荐文章于 2024-07-11 17:07:22 发布