更新JSONb值

时间:2018-11-12 10:32:41

标签: postgresql

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

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

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

先谢谢了!

1 个答案:

答案 0 :(得分:3)

您可以使用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

相关问题