在Postgres中,我有一个像这样的表:
事情是这样的,我想更新
我知道如何更改整个
CREATE TABLE storehouse
(
user_id bigint NOT NULL,
capacity integer NOT NULL,
storehouse json NOT NULL,
last_modified timestamp without time zone NOT NULL,
CONSTRAINT storehouse_pkey PRIMARY KEY (user_id)
)
而 storehouse.storehouse
存储的数据如下:
{
"slots":[
{
"slot" : 1,
"id" : 938
},
{
"slot" : 2,
"id" : 127
},
]
}
事情是这样的,我想更新
storehouse.storehouse.slots [2]
,但我不知道如何做到。我知道如何更改整个
storehouse.storehouse
字段,但我在想,由于Postgres支持json
类型,它应该支持部分修改,否则json
类型和text
类型之间没有区别。(我知道json
类型还具有类型验证,与text
不同)