Use multiple conflict_target in ON CONFLICT clause

前端 未结 9 791
傲寒
傲寒 2020-11-29 02:25

I have two columns in table col1, col2, they both are unique indexed (col1 is unique and so is col2).

I need at insert into this table, u

9条回答
  •  情深已故
    2020-11-29 02:41

    Vlad got the right idea.

    First you have to create a table unique constraint on the columns col1, col2 Then once you do that you can do the following:

    INSERT INTO dupes values(3,2,'c') 
    ON CONFLICT ON CONSTRAINT dupes_pkey 
    DO UPDATE SET col3 = 'c', col2 = 2
    

提交回复
热议问题