The SHOW CONSTRAINTSstatement lists all named constraints as well as any unnamed CHECK constraints on a table.
Required privileges
The user must have any privilege on the target table.
Aliases
SHOW CONSTRAINT is an alias for SHOW CONSTRAINTS.
Synopsis
Parameters
Parameter
Description
table_name
The name of the table for which to show constraints.
Response
The following fields are returned for each constraint.
Field
Description
table_name
The name of the table.
constraint_name
The name of the constraint.
constraint_type
The type of constraint.
details
The definition of the constraint, including the column(s) to which it applies.
validated
Whether values in the column(s) match the constraint.
Example
> CREATE TABLE orders ( id INT PRIMARY KEY, date TIMESTAMP NOT NULL, priority INT DEFAULT 1, customer_id INT UNIQUE, status STRING DEFAULT 'open', CHECK (priority BETWEEN 1 AND 5), CHECK (status in ('open', 'in progress', 'done', 'cancelled')), FAMILY (id, date, priority, customer_id, status));