DBAtlas · Database operations atlas

23514: check_violation

PostgreSQL

What does it mean?

A CHECK constraint was violated. The inserted or updated row does not satisfy a logical condition defined on the table (e.g. price > 0).

Why does it happen?

Data violating a business rule (negative price, invalid status code, date range violation); no validation on the application side; a constraint too strict for the data; records breaking the rule during a bulk load.

How to fix it

Use the constraint name in the error message to find which condition was violated; view the definition: \d table_name. Query the violating rows by inverting the condition. Fix the data, or if the rule has really changed, update the constraint: ALTER TABLE my_table DROP CONSTRAINT name; ALTER TABLE my_table ADD CONSTRAINT name CHECK (new_condition);

Open in DBAtlas →

More from this engine