Created
March 23, 2018 15:45
-
-
Save sgraham785/abd9ff294b6bcc1ee0236ced4e62e89a to your computer and use it in GitHub Desktop.
Examples of PostgreSQL Upsert
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
INSERT INTO users (id, level) | |
VALUES (1, 0) | |
ON CONFLICT (id) DO UPDATE | |
SET level = users.level + 1; | |
INSERT INTO users (id, email) | |
VALUES (1, [email protected]) | |
ON CONFLICT (id) DO UPDATE | |
SET email = EXCLUDED.email; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment