Last active
January 17, 2017 13:38
-
-
Save mdiener21/7268fe52623cad218a357276b9d1f650 to your computer and use it in GitHub Desktop.
update a jsonb postgresql field from columns data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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