Created
March 30, 2015 14:59
-
-
Save andybeak/750afee1bccd3e3fddf3 to your computer and use it in GitHub Desktop.
Ignore duplicate inserts in Postgre SQL
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
CREATE OR REPLACE RULE db_table_ignore_duplicate_inserts AS | |
ON INSERT TO db_table | |
WHERE (EXISTS ( SELECT 1 | |
FROM db_table | |
WHERE db_table.tbl_column = NEW.tbl_column)) DO INSTEAD NOTHING; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment