The pg_constraint system catalog table stores check, primary key, unique, and foreign key constraints on tables. Column constraints are not treated specially. Every column constraint is equivalent to some table constraint. Not-null constraints are represented in the pg_attribute catalog table. Check constraints on domains are stored here, too.

    columntypereferencesdescription
    connamename Constraint name (not necessarily unique!)
    connamespaceoidpg_namespace.oidThe OID of the namespace (schema) that contains this constraint.
    contypechar c = check constraint, f = foreign key constraint, p = primary key constraint, u = unique constraint.
    condeferrableboolean Is the constraint deferrable?
    condeferredboolean Is the constraint deferred by default?
    convalidatedboolean Has the constraint been validated? Currently, can only be false for foreign keys
    conrelidoidpg_class.oidThe table this constraint is on; 0 if not a table constraint.
    contypidoidpg_type.oidThe domain this constraint is on; 0 if not a domain constraint.
    conindidoidpg_class.oidThe index supporting this constraint, if it’s a unique, primary key, foreign key, or exclusion constraint; else 0
    confrelidoidpg_class.oidIf a foreign key, the referenced table; else 0.
    confupdtypechar Foreign key update action code.
    confdeltypechar Foreign key deletion action code.
    confmatchtypechar Foreign key match type.
    conislocalboolean This constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously.
    coninhcountint4 The number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed.
    conkeyint2[]pg_attribute.attnumIf a table constraint, list of columns which the constraint constrains.
    confkeyint2[]pg_attribute.attnumIf a foreign key, list of the referenced columns.
    conpfeqopoid[]pg_operator.oidIf a foreign key, list of the equality operators for PK = FK comparisons.
    conppeqopoid[]pg_operator.oidIf a foreign key, list of the equality operators for PK = PK comparisons.
    conffeqopoid[]pg_operator.oidIf a foreign key, list of the equality operators for PK = PK comparisons.
    conexclopoid[]pg_operator.oidIf an exclusion constraint, list of the per-column exclusion operators.
    conbintext If a check constraint, an internal representation of the expression.
    consrctext If a check constraint, a human-readable representation of the expression. This is not updated when referenced objects change; for example, it won’t track renaming of columns. Rather than relying on this field, it is best to use pg_get_constraintdef() to extract the definition of a check constraint.

    Parent topic: System Catalogs Definitions