Skip to content
Advertisement

how to update value of key in json type field on PostgreSQL

I am running postgresql 9.6 version. I am storing data in json type field.

I want to update “flag” to “False”.

What query i have to use?

Advertisement

Answer

Here is one way to do it:

Demo on DB Fiddle:

name  | jsonvalues                                 
:---- | :------------------------------------------
Jacky | {"flag": "False", "has_attachment": "True"}

Note that your original insert query is not valid Postgres syntax. You need single quotes around the values, and double quotes within the JSON, so that should be:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement