In Postgres, I have a table like this:
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) )
And storehouse.storehouse stores this data:
{ "slots":[ { "slot" : 1, "id" : 938 }, { "slot" : 2, "id" : 127 }, ] }
The fact is that I want to update storehouse.storehouse.slots[2] , but I have no idea how to do this.
I know how to change the entire storehouse.storehouse field, but I'm interested, since Postgres supports the json type, it must support partial change, otherwise there will be no difference between the json type and the text type. (I know that json type also has type checking that is different from text )
source share