我在同一张表上有两个唯一约束条件,并且我想在该表上执行upsert语句。
是否可以在upsert中指定这两个冲突? 我看到了这个:如何在Postgres中upsert其中一个列的冲突?
但我的问题稍微复杂一些,因为其中一个唯一约束是另一个唯一约束的子集。 即
unique_constraint_1 =(col_1) unqiue_constraint_2 =(col_1,col_2)
INSERT INTO table (col_1, col_2, col_3)
VALUES (val_1, val_2, val_3)
ON CONFLICT (what do I put here to account for both constraints?)
DO NOTHING;
谢谢!
UserTable
和以下约束条件:on conflict ( first_name, last_name), (city, street,number,last_name) )
时,与你提出的on conflict ( first_name,city, street,number,last_name) )
的含义不同,如果我理解正确的话。注意:unique(id)未包含在on conflict
子句中。 - claus