The TABLE_CONSTRAINTS
table describes
which tables have constraints.
The TABLE_CONSTRAINTS
table has these
columns:
CONSTRAINT_CATALOG
The name of the catalog to which the constraint belongs. This value is always
def
.CONSTRAINT_SCHEMA
The name of the schema (database) to which the constraint belongs.
TABLE_SCHEMA
The name of the schema (database) to which the table belongs.
TABLE_NAME
The name of the table.
The
CONSTRAINT_TYPE
The type of constraint. The value can be
UNIQUE
,PRIMARY KEY
,FOREIGN KEY
, or (as of MySQL 8.0.16)CHECK
. This is aCHAR
(notENUM
) column.The
UNIQUE
andPRIMARY KEY
information is about the same as what you get from theKey_name
column in the output fromSHOW INDEX
when theNon_unique
column is0
.ENFORCED
For
CHECK
constraints, the value isYES
orNO
to indicate whether the constraint is enforced. For other constraints, the value is alwaysYES
.This column was added in MySQL 8.0.16.