The view information_schema.check_constraints contains all check constraints defined on a table.
SELECT * FROM information_schema.check_constraints;
SELECT constraint_schema, table_name, constraint_name, check_clause
FROM information_schema.check_constraints;
information_schema.check_constraints
| column name | type | remarks |
|---|---|---|
| constraint_catalog | VARCHAR | Always NULL |
| constraint_schema | VARCHAR | |
| constraint_name | VARCHAR | |
| check_clause | VARCHAR | |
| schema_id | INTEGER | reference to sys.schemas.id |
| table_id | INTEGER | reference to sys.tables.id |
| table_name | INTEGER | name of table which has the check constraint |
| key_id | INTEGER | reference to sys.keys.id |
Note: The last 4 columns (schema_id, table_id, table_name and key_id) are extensions to the view as defined by ISO standard. They provide useful information and simplify filtering and joins with system tables/views in sys schema when needed.