Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
53.13. pg_constraint
Prev UpChapter 53. System CatalogsHome Next

53.13. pg_constraint

The catalogpg_constraint stores check, primary key, unique, foreign key, and exclusion constraints on tables. (Column constraints are not treated specially. Every column constraint is equivalent to some table constraint.) Not-null constraints are represented in thepg_attribute catalog, not here.

User-defined constraint triggers (created withCREATE CONSTRAINT TRIGGER) also give rise to an entry in this table.

Check constraints on domains are stored here, too.

Table 53.13. pg_constraint Columns

Column Type

Description

oidoid

Row identifier

connamename

Constraint name (not necessarily unique!)

connamespaceoid (referencespg_namespace.oid)

The OID of the namespace that contains this constraint

contypechar

c = check constraint,f = foreign key constraint,p = primary key constraint,u = unique constraint,t = constraint trigger,x = exclusion constraint

condeferrablebool

Is the constraint deferrable?

condeferredbool

Is the constraint deferred by default?

convalidatedbool

Has the constraint been validated? Currently, can be false only for foreign keys and CHECK constraints

conrelidoid (referencespg_class.oid)

The table this constraint is on; zero if not a table constraint

contypidoid (referencespg_type.oid)

The domain this constraint is on; zero if not a domain constraint

conindidoid (referencespg_class.oid)

The index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else zero

conparentidoid (referencespg_constraint.oid)

The corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zero

confrelidoid (referencespg_class.oid)

If a foreign key, the referenced table; else zero

confupdtypechar

Foreign key update action code:a = no action,r = restrict,c = cascade,n = set null,d = set default

confdeltypechar

Foreign key deletion action code:a = no action,r = restrict,c = cascade,n = set null,d = set default

confmatchtypechar

Foreign key match type:f = full,p = partial,s = simple

conislocalbool

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.

connoinheritbool

This constraint is defined locally for the relation. It is a non-inheritable constraint.

conkeyint2[] (referencespg_attribute.attnum)

If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columns

confkeyint2[] (referencespg_attribute.attnum)

If a foreign key, list of the referenced columns

conpfeqopoid[] (referencespg_operator.oid)

If a foreign key, list of the equality operators for PK = FK comparisons

conppeqopoid[] (referencespg_operator.oid)

If a foreign key, list of the equality operators for PK = PK comparisons

conffeqopoid[] (referencespg_operator.oid)

If a foreign key, list of the equality operators for FK = FK comparisons

confdelsetcolsint2[] (referencespg_attribute.attnum)

If a foreign key with aSET NULL orSET DEFAULT delete action, the columns that will be updated. If null, all of the referencing columns will be updated.

conexclopoid[] (referencespg_operator.oid)

If an exclusion constraint, list of the per-column exclusion operators

conbinpg_node_tree

If a check constraint, an internal representation of the expression. (It's recommended to usepg_get_constraintdef() to extract the definition of a check constraint.)


In the case of an exclusion constraint,conkey is only useful for constraint elements that are simple column references. For other cases, a zero appears inconkey and the associated index must be consulted to discover the expression that is constrained. (conkey thus has the same contents aspg_index.indkey for the index.)

Note

pg_class.relchecks needs to agree with the number of check-constraint entries found in this table for each relation.


Prev Up Next
53.12. pg_collation Home 53.14. pg_conversion
pdfepub
Go to PostgreSQL 15
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp