3819: ER_CHECK_CONSTRAINT_VIOLATED: Check constraint is violated
MySQLWhat does it mean?
The row you are inserting or updating violates a CHECK constraint defined on the table. In MySQL 8.0.16 and later, CHECK constraints are actually enforced (earlier versions ignored them).
Why does it happen?
The column value does not satisfy the condition in the CHECK expression (e.g. entering a negative price when CHECK (price >= 0) exists). After upgrading from older MySQL versions to 8.0.16+, it can appear unexpectedly because previously ignored constraints are now enforced.
How to fix it
Make sure the value satisfies the constraint condition; add validation on the application side. To see the constraint definition: SHOW CREATE TABLE my_table; If the constraint is truly unnecessary: ALTER TABLE my_table DROP CHECK constraint_name; or temporarily ALTER TABLE my_table ALTER CHECK constraint_name NOT ENFORCED; Also fix the source of the bad data.
More from this engine
- 1927MariaDB: ER_CONNECTION_KILLED: Connection was killed
- 1290ER_OPTION_PREVENTS_STATEMENT: running with the --read-only option
- 1836ER_READ_ONLY_MODE: Running in read-only mode
- 1118ER_TOO_BIG_ROWSIZE: Row size too large
- 1170ER_BLOB_KEY_WITHOUT_LENGTH: BLOB/TEXT column used in key specification without a key length
- 1592ER_BINLOG_UNSAFE_STATEMENT: Unsafe statement written to the binary log
- 3140ER_INVALID_JSON_TEXT: Invalid JSON text