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

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -