gpt4 book ai didi

postgresql - 更新 JSONb 值

转载 作者:行者123 更新时间:2023-11-29 14:14:38 25 4
gpt4 key购买 nike

我想更新 PostgreSQL 表中的 JSONb 值,这里是他的原型(prototype):

{
key1: {
key2: {
key3: value
...
}
...
}
...
}

我想更新key1->key2->>key3

最佳答案

您可以为此使用 jsonb_set():

update the_table
set the_column = jsonb_set(the_column, '{key1,key2}', '{"key3": "new_value"}')
where the_pk_column = 42;

在线示例:https://rextester.com/CEWF51936

关于postgresql - 更新 JSONb 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53260292/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com