Last active
August 29, 2015 13:57
-
-
Save porjo/9886861 to your computer and use it in GitHub Desktop.
Postgresql: JSON operations cheatcheet
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
-- Select empty JSON field | |
select * from mytable where jsonfield::text = '{}' | |
-- Select 'title' within JSON field | |
select * from mytable where jsonfield->>'title' = 'Great Expectations' | |
select * from mytable where jsonfield->>'title' like 'Great Expectations%' | |
-- Update: Postgres 9.3 you must update whole field | |
update mytable set jsonfield = '{}' where id = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment