Skip to content

Instantly share code, notes, and snippets.

@Tyralion
Created October 28, 2016 05:50
Show Gist options
  • Save Tyralion/2da41661a8326175c7c13ae001c5fd0a to your computer and use it in GitHub Desktop.
Save Tyralion/2da41661a8326175c7c13ae001c5fd0a to your computer and use it in GitHub Desktop.
inser or update
create table test (a varchar(255), b varchar(255), c integer);
create unique index idx_test_a_b on test (a, b);
insert into test values ('a', 'foo', 1);
select * from test;
insert into test values ('a', 'foo', 1) on conflict (a, b) do update set a = 'c';
select * from test;
drop table test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment