更新 JSONb 值
Update JSONb value
我想在 PostgreSQL table 中更新一个 JSONb 值,这里是他的原型:
{
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;
我想在 PostgreSQL table 中更新一个 JSONb 值,这里是他的原型:
{
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;