Information Schema CHECK_CONSTRAINTS Table
The Information Schema CHECK_CONSTRAINTS table stores metadata about the constraints defined for tables in all databases, including the check clause.
The Information Schema CHECK_CONSTRAINTS table stores metadata about the constraints defined for tables in all databases.
It contains the following columns:
CONSTRAINT_CATALOG
Always contains the string 'def'.
CONSTRAINT_SCHEMA
Database name.
CONSTRAINT_NAME
Constraint name.
TABLE_NAME
Table name.
LEVEL
Type of the constraint ('Column' or 'Table'). From MariaDB 10.5.10.
CHECK_CLAUSE
Constraint clause.
Example
A table with a numeric table check constraint and with a default check constraint name:
CREATE TABLE t ( a INT, CHECK (a>10));To see check constraint call check_constraints table from information schema.
SELECT * FROM INFORMATION_SCHEMA.CHECK_CONSTRAINTS\G*************************** 1. row ***************************
CONSTRAINT_CATALOG: def
CONSTRAINT_SCHEMA: test
CONSTRAINT_NAME: CONSTRAINT_1
TABLE_NAME: t
CHECK_CLAUSE: `a` > 10A new table check constraint called a_upper:
A new table tt with a field check constraint called b , as well as a table check constraint called b_upper:
Note: The name of the field constraint is the same as the field name.
After dropping the default table constraint called CONSTRAINT_1:
Trying to insert invalid arguments into table t and tt generates an error.
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

