postgresql - How to upsert in Postgres on conflict on one of 2 columns? -


is possible upsert in postgres 9.5 when conflict happens on 1 of 2 columns in table.? have 2 columns , if either column throws unique constraint violation, perform update operation.

yes, , behaviour default. unique constraint violation constitutes conflict , update performed if on conflict update specified. insert statement can have single on conflict clause, conflict_target of clause can specify multiple column names each of must have index, such unique constraint. are, however, limited single conflict_action , not have information on constraint caused conflict when processing action. if need kind of information, or specific action depending on constraint violation, should write trigger function lose all-important atomicity of insert ... on conflict ... statement.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -

r - Update two sets of radiobuttons reactively - shiny -