我有jsonb
列,其中包含下一个数据:
{
'key1': 'data1'
}
带有一些物体:
const myObj = {
'key2': 'data2'
}
我需要编写SQL查询以将myObj
添加到jsonb
列中,结果如下:
{
'key1': 'data1',
'key2': 'data2'
}
答案 0 :(得分:1)
使用||
运算符,即
update <tablename>
set jsonb_column = jsonb_column || '{"key2":"data2"}'::jsonb
where ...
这里是documentation
。