CHECK constraint

  • The CHECK constraint tab allows inserting/update the data after evaluating an expression/condition. If any of the constraints fails, then the data is not inserted/updated
  • If there is more than one table-level CHECK constraint, then they are evaluated in the order they are defined.
  • The CHECK constraints are enforced in MariaDB since 10.2.1. Before v10.2.1, the constraint expressions were accepted in the syntax but ignored.
  • MySQL also ignores the check constraints
  • From MariaDB v10.2.1 onwards, the CHECK constraints can be defined in two ways,
    • As part of a column definition
    • It can be defined as a table level constraint. For e.g.,CONSTRAINT [constraint_name] CHECK (expression)
  • CHECK constraints cannot be altered. It is only possible to drop them and re-add them
  • From MariaDB v10.2.1+, the CHECK constraint can be turned off >> https://mariadb.com/kb/en/library/server-system-variables/#check_constraint_checks