Home > database >  Also update the jsonb postgresql several key values in a field
Also update the jsonb postgresql several key values in a field

Time:09-21

For postgresql database, a field is jsonb, this field to save a json, the json has a number of key and the corresponding value, so how to use a statement of the json update a number of key value? Or how to update the best?
I update a key statement is as follows:

The UPDATE table
The SET jsonb_ccolumn=jsonb_set (jsonb_ccolumn json_path, value)
WHERE [condition];

CodePudding user response:

The UPDATE table SET jsonb_ccolumn=(jsonb_ccolumn | | '{" name ":" zhangsan three ", "need" : 1}') WHERE id=12183782;

CodePudding user response:

One side effect, if the key repeat, be overwritten!
  • Related