我想尝试两种情况。我在具有这样结构的表中有一个jsonb列:
{
"1": {
"a": 0.084,
"b": 0.084,
"c": 0.084
},
"2": {
"a": 0.078,
"b": 0.0814,
"c": 0.078
},
"3": {
"a": 0.0928,
"b": 0.0975,
"c": 0.0975
}
}
如果我想更改“ 3”:{“ b”:}的值,我该怎么做?我尝试查看jsonb_set()之类的函数,但似乎每次我要更新一个值时,我都必须复制整个jsonb对象并重新粘贴它。
我要解决的第二个问题是是否要删除整个“ 3”:{}对象,我似乎可以找到的唯一解决方案是再次使用jsonb_set()。
谢谢你的帮助!
You can use
jsonb_set()
function with the related path'{3,b}'
in order toupdate
:其中0.1只是一个样本值
Use
#-
operator in order todelete
:Demo