Created
January 31, 2015 04:40
-
-
Save rohit-gupta/5806b68d022beb05c37e to your computer and use it in GitHub Desktop.
query to carry out an upsert in postgres
This file contains 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
begin; | |
lock my_table in exclusive mode; | |
delete from my_table where key='key'; | |
insert into my_table (key, value) values ('key', 'value'); | |
commit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment