Skip to content

Instantly share code, notes, and snippets.

@mdiener21
Last active January 17, 2017 13:38
Show Gist options
  • Save mdiener21/7268fe52623cad218a357276b9d1f650 to your computer and use it in GitHub Desktop.
Save mdiener21/7268fe52623cad218a357276b9d1f650 to your computer and use it in GitHub Desktop.
update a jsonb postgresql field from columns data
update tableName set columnName = json_build_object('keyfieldname1',fieldname1,'keyfieldname2',fieldname2)
-- keyfieldname1 is any text name you give to the key
-- fieldname1 is an existing column name you have in your table
-- docs https://www.postgresql.org/docs/9.5/static/functions-json.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment