バージョンごとのドキュメント一覧

53.13. pg_constraint #

The catalog <structname>pg_constraint</structname> 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 the <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link> catalog, not here. pg_constraintカタログはテーブル上の検査制約、主キー制約、一意性制約、外部キー制約、排他制約を格納します (列制約は特別扱いされていません。 全ての列制約は何らかのテーブル制約と同等です。) 非NULL制約はここではなく、pg_attributeカタログで示されます。

User-defined constraint triggers (created with <link linkend="sql-createtrigger"> <command>CREATE CONSTRAINT TRIGGER</command></link>) also give rise to an entry in this table. CREATE CONSTRAINT TRIGGERで作成される)ユーザ定義の制約トリガもこのテーブルの項目の元になります。

Check constraints on domains are stored here, too. ドメイン上の検査制約もここに格納されます。

表53.13 pg_constraintの列

<title><structname>pg_constraint</structname> Columns</title>

Column Type 列 型

Description 説明

oid oid

Row identifier 行識別子

conname name

Constraint name (not necessarily unique!) 制約名(一意である必要はありません!)

connamespace oid (references <link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.<structfield>oid</structfield>) (参照先 pg_namespace.oid

The OID of the namespace that contains this constraint この制約を含む名前空間のOID

contype char

<literal>c</literal> = check constraint, <literal>f</literal> = foreign key constraint, <literal>p</literal> = primary key constraint, <literal>u</literal> = unique constraint, <literal>t</literal> = constraint trigger, <literal>x</literal> = exclusion constraint c = 検査制約、 f = 外部キー制約、 p = 主キー制約、 u = 一意性制約、 t = 制約トリガ、 x = 排他制約

condeferrable bool

Is the constraint deferrable? 制約は遅延可能かどうか?

condeferred bool

Is the constraint deferred by default? 制約はデフォルトで遅延可能かどうか?

convalidated bool

Has the constraint been validated? Currently, can be false only for foreign keys and CHECK constraints 制約が検証されているか? 現時点では外部キーとチェック制約の場合のみfalseになる可能性があります

conrelid oid (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>) (参照先 pg_class.oid

The table this constraint is on; zero if not a table constraint この制約が存在しているテーブル。 テーブル制約でなければゼロ

contypid oid (references <link linkend="catalog-pg-type"><structname>pg_type</structname></link>.<structfield>oid</structfield>) (参照先 pg_type.oid

The domain this constraint is on; zero if not a domain constraint この制約が存在しているドメイン。 ドメイン制約でなければゼロ

conindid oid (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>) (参照先 pg_class.oid

The index supporting this constraint, if it's a unique, primary key, foreign key, or exclusion constraint; else zero 一意性制約、主キー制約、外部キー制約、排他制約の場合、この制約をサポートするインデックス。 そうでなければゼロ

conparentid oid (references <link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link>.<structfield>oid</structfield>) (参照先 pg_constraint.oid

The corresponding constraint of the parent partitioned table, if this is a constraint on a partition; else zero パーティション内の制約なら、親パーティションテーブルの該当制約。 そうでなければゼロ

confrelid oid (references <link linkend="catalog-pg-class"><structname>pg_class</structname></link>.<structfield>oid</structfield>) (参照先 pg_class.oid

If a foreign key, the referenced table; else zero 外部キーであれば、参照されるテーブル。 そうでなければゼロ

confupdtype char

Foreign key update action code: <literal>a</literal> = no action, <literal>r</literal> = restrict, <literal>c</literal> = cascade, <literal>n</literal> = set null, <literal>d</literal> = set default 外部キー更新アクションコード: a = no action, r = restrict, c = cascade, n = set null, d = set default

confdeltype char

Foreign key deletion action code: <literal>a</literal> = no action, <literal>r</literal> = restrict, <literal>c</literal> = cascade, <literal>n</literal> = set null, <literal>d</literal> = set default 外部キー削除アクションコード: a = no action, r = restrict, c = cascade, n = set null, d = set default

confmatchtype char

Foreign key match type: <literal>f</literal> = full, <literal>p</literal> = partial, <literal>s</literal> = simple 外部キーの一致型: f = full, p = partial, s = simple

conislocal bool

This constraint is defined locally for the relation. Note that a constraint can be locally defined and inherited simultaneously. この制約はリレーションでローカルに定義されています。制約はローカルに定義されていて同時に継承されます。

coninhcount int2

The number of direct inheritance ancestors this constraint has. A constraint with a nonzero number of ancestors cannot be dropped nor renamed. この制約がもつ直系の先祖の数。 先祖の数がゼロではない制約は削除や改名はできません。

connoinherit bool

This constraint is defined locally for the relation. It is a non-inheritable constraint. この制約はリレーションのためにローカルで定義されます。これは非継承制約です。

conkey int2[] (references <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.<structfield>attnum</structfield>) (参照先 pg_attribute.attnum

If a table constraint (including foreign keys, but not constraint triggers), list of the constrained columns テーブル制約(外部キーを含みますが制約トリガは含みません)であれば、その制約によって制約される列のリスト

confkey int2[] (references <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.<structfield>attnum</structfield>) (参照先 pg_attribute.attnum

If a foreign key, list of the referenced columns 外部キーであれば、参照される列のリスト

conpfeqop oid[] (references <link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.<structfield>oid</structfield>) (参照先 pg_operator.oid

If a foreign key, list of the equality operators for PK = FK comparisons 外部キーであれば、PK = FKの比較のための同値演算子のリスト

conppeqop oid[] (references <link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.<structfield>oid</structfield>) (参照先 pg_operator.oid

If a foreign key, list of the equality operators for PK = PK comparisons 外部キーであれば、PK = PKの比較のための同値演算子のリスト

conffeqop oid[] (references <link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.<structfield>oid</structfield>) (参照先 pg_operator.oid

If a foreign key, list of the equality operators for FK = FK comparisons 外部キーであれば、FK = FKの比較のための同値演算子のリスト

confdelsetcols int2[] (references <link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.<structfield>attnum</structfield>) (参照先 pg_attribute.attnum

If a foreign key with a <literal>SET NULL</literal> or <literal>SET DEFAULT</literal> delete action, the columns that will be updated. If null, all of the referencing columns will be updated. 外部キーにSET NULLまたはSET DEFAULT削除アクションがある場合、更新される列。 NULLの場合、参照しているすべての列が更新されます。

conexclop oid[] (references <link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.<structfield>oid</structfield>) (参照先 pg_operator.oid

If an exclusion constraint, list of the per-column exclusion operators 排他制約の場合、列単位の排他演算子のリスト

conbin pg_node_tree

If a check constraint, an internal representation of the expression. (It's recommended to use <function>pg_get_constraintdef()</function> to extract the definition of a check constraint.) チェック制約なら式の内部表現。(pg_get_constraintdef()を使ってチェック制約の定義を取り出すことをお勧めします。)


In the case of an exclusion constraint, <structfield>conkey</structfield> is only useful for constraint elements that are simple column references. For other cases, a zero appears in <structfield>conkey</structfield> and the associated index must be consulted to discover the expression that is constrained. (<structfield>conkey</structfield> thus has the same contents as <link linkend="catalog-pg-index"><structname>pg_index</structname></link>.<structfield>indkey</structfield> for the index.) 排他制約の場合、単純な列参照である制約要素でのみconkeyが有用です。 その他の場合、conkeyはゼロであり、関連するインデックスは制約される式を調査して見つけなければなりません。 (したがってインデックスではconkeypg_index.indkeyの内容と同じものを持ちます。)

注記

<literal>pg_class.relchecks</literal> needs to agree with the number of check-constraint entries found in this table for each relation. pg_class.relchecksはそれぞれのリレーションに対してこのテーブルで検出された検査制約の項目数と一致しなければなりません。