List all check constraints in PostgreSQL database

Query below lists check constraints defined in the database ordered by constraint name.

Check this query to see them organized by table.


select pgc.conname as constraint_name,
       ccu.table_schema as table_schema,
       pgc.consrc as definition
from pg_constraint pgc
join pg_namespace nsp on nsp.oid = pgc.connamespace
join pg_class  cls on pgc.conrelid = cls.oid
left join information_schema.constraint_column_usage ccu
          on pgc.conname = ccu.constraint_name
          and nsp.nspname = ccu.constraint_schema
where contype ='c'
order by pgc.conname;


  • constraint_name - name of the constraint in the database
  • table_schema - table's schema name constraint is defined for, null for not table-level check constraints
  • table_name - table name constraint is defined for, null for not table-level check constraints
  • column_name - name of the column for column-level check constraints, null for not table-level check constraints
  • is_deffered - indicate if the constraint deferred by default
  • definition - SQL expression that defines this check constraint


  • One row represents one check constraint
  • Scope of rows: query returns all check constraints in the database
  • Ordered by constraint name

Sample results

List of check constraints in pagila database.

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.