Skip to content

Instantly share code, notes, and snippets.

@ugnb
Created December 2, 2017 02:40
Show Gist options
  • Save ugnb/294c3403a312129957902a5f6fdf201b to your computer and use it in GitHub Desktop.
Save ugnb/294c3403a312129957902a5f6fdf201b to your computer and use it in GitHub Desktop.
Postgresql: Update row with insertion values in case of conflict
INSERT INTO table1
(id, column1, column2, column3)
VALUES
(:id, :column1, :column2, :column3)
ON CONFLICT (id) DO UPDATE
SET
column1 = EXCLUDED.column1,
column2 = EXCLUDED.column2,
column3 = EXCLUDED.column3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment