Skip to main content
edited tags
Link
Erwin Brandstetter
  • 186.6k
  • 28
  • 465
  • 639
Tweeted twitter.com/StackDBAs/status/994614539147718657
Source Link
user606521
  • 1.4k
  • 6
  • 23
  • 28

Multiple on conflict targets

I have two unique indexes on columns a and b. I need something like this:

insert into my_table (a, b) values (1, 2), (1, 2) on conflict (a) do update set c = 'a_violation' on conflict (b) do update set c = 'b_violation' 

So generally I want to make different update based on conflict target - syntax above is not supported (only one on conflict statement is supported). Is there any other way to do this?