问题
There is a constraint violation handling "On conflict" statement, working fine if i want to check 1 (!) constraint
For example :
INSERT INTO my_table (co1,col2..colN)
VALUES (...)
ON CONFLICT (col1, col2) DO NOTHING --or update
But if i have 2 constaints unique(col1,col2)
and unique(col5,col6,col7)
, the query below is not working :
INSERT INTO my_table (co1,col2..colN)
VALUES (...)
ON CONFLICT (col1, col2) DO NOTHING --or update
ON CONFLICT (col5, col6, col7) DO NOTHING --or update
This raises the error, pointing on : ERROR: syntax error at or near "on". LINE _: on conflict (col5, col6, col7) do nothing
How could i resolve using multiple constraint checking in one query?
来源:https://stackoverflow.com/questions/52236263/postgresql-on-conflict-with-multiple-constraints