Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 9b6cc37ce608401d44f6535a0c7cb777 > files > 83

postgresql11-docs-11.5-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>52.13. pg_constraint</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="catalog-pg-collation.html" title="52.12. pg_collation" /><link rel="next" href="catalog-pg-conversion.html" title="52.14. pg_conversion" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">52.13. <code xmlns="http://www.w3.org/1999/xhtml" class="structname">pg_constraint</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="catalog-pg-collation.html" title="52.12. pg_collation">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="catalogs.html" title="Chapter 52. System Catalogs">Up</a></td><th width="60%" align="center">Chapter 52. System Catalogs</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 11.5 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="catalog-pg-conversion.html" title="52.14. pg_conversion">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="CATALOG-PG-CONSTRAINT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">52.13. <code class="structname">pg_constraint</code></h2></div></div></div><a id="id-1.10.4.15.2" class="indexterm"></a><p>
   The catalog <code class="structname">pg_constraint</code> 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 <code class="structname">pg_attribute</code>
   catalog, not here.
  </p><p>
   User-defined constraint triggers (created with <code class="command">CREATE CONSTRAINT
   TRIGGER</code>) also give rise to an entry in this table.
  </p><p>
   Check constraints on domains are stored here, too.
  </p><div class="table" id="id-1.10.4.15.6"><p class="title"><strong>Table 52.13. <code class="structname">pg_constraint</code> Columns</strong></p><div class="table-contents"><table class="table" summary="pg_constraint Columns" border="1"><colgroup><col /><col /><col /><col /></colgroup><thead><tr><th>Name</th><th>Type</th><th>References</th><th>Description</th></tr></thead><tbody><tr><td><code class="structfield">oid</code></td><td><code class="type">oid</code></td><td> </td><td>Row identifier (hidden attribute; must be explicitly selected)</td></tr><tr><td><code class="structfield">conname</code></td><td><code class="type">name</code></td><td> </td><td>Constraint name (not necessarily unique!)</td></tr><tr><td><code class="structfield">connamespace</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-namespace.html" title="52.32. pg_namespace"><code class="structname">pg_namespace</code></a>.oid</code></td><td>
       The OID of the namespace that contains this constraint
      </td></tr><tr><td><code class="structfield">contype</code></td><td><code class="type">char</code></td><td> </td><td>
        <code class="literal">c</code> = check constraint,
        <code class="literal">f</code> = foreign key constraint,
        <code class="literal">p</code> = primary key constraint,
        <code class="literal">u</code> = unique constraint,
        <code class="literal">t</code> = constraint trigger,
        <code class="literal">x</code> = exclusion constraint
      </td></tr><tr><td><code class="structfield">condeferrable</code></td><td><code class="type">bool</code></td><td> </td><td>Is the constraint deferrable?</td></tr><tr><td><code class="structfield">condeferred</code></td><td><code class="type">bool</code></td><td> </td><td>Is the constraint deferred by default?</td></tr><tr><td><code class="structfield">convalidated</code></td><td><code class="type">bool</code></td><td> </td><td>Has the constraint been validated?
       Currently, can only be false for foreign keys and CHECK constraints</td></tr><tr><td><code class="structfield">conrelid</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.oid</code></td><td>The table this constraint is on; 0 if not a table constraint</td></tr><tr><td><code class="structfield">contypid</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-type.html" title="52.62. pg_type"><code class="structname">pg_type</code></a>.oid</code></td><td>The domain this constraint is on; 0 if not a domain constraint</td></tr><tr><td><code class="structfield">conindid</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.oid</code></td><td>The index supporting this constraint, if it's a unique, primary
       key, foreign key, or exclusion constraint; else 0</td></tr><tr><td><code class="structfield">conparentid</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-constraint.html" title="52.13. pg_constraint"><code class="structname">pg_constraint</code></a>.oid</code></td><td>The corresponding constraint in the parent partitioned table,
       if this is a constraint in a partition; else 0</td></tr><tr><td><code class="structfield">confrelid</code></td><td><code class="type">oid</code></td><td><code class="literal"><a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.oid</code></td><td>If a foreign key, the referenced table; else 0</td></tr><tr><td><code class="structfield">confupdtype</code></td><td><code class="type">char</code></td><td> </td><td>Foreign key update action code:
            <code class="literal">a</code> = no action,
            <code class="literal">r</code> = restrict,
            <code class="literal">c</code> = cascade,
            <code class="literal">n</code> = set null,
            <code class="literal">d</code> = set default
          </td></tr><tr><td><code class="structfield">confdeltype</code></td><td><code class="type">char</code></td><td> </td><td>Foreign key deletion action code:
            <code class="literal">a</code> = no action,
            <code class="literal">r</code> = restrict,
            <code class="literal">c</code> = cascade,
            <code class="literal">n</code> = set null,
            <code class="literal">d</code> = set default
          </td></tr><tr><td><code class="structfield">confmatchtype</code></td><td><code class="type">char</code></td><td> </td><td>Foreign key match type:
            <code class="literal">f</code> = full,
            <code class="literal">p</code> = partial,
            <code class="literal">s</code> = simple
          </td></tr><tr><td><code class="structfield">conislocal</code></td><td><code class="type">bool</code></td><td> </td><td>
       This constraint is defined locally for the relation.  Note that a
       constraint can be locally defined and inherited simultaneously.
      </td></tr><tr><td><code class="structfield">coninhcount</code></td><td><code class="type">int4</code></td><td> </td><td>
       The number of direct inheritance ancestors this constraint has.
       A constraint with
       a nonzero number of ancestors cannot be dropped nor renamed.
      </td></tr><tr><td><code class="structfield">connoinherit</code></td><td><code class="type">bool</code></td><td> </td><td>
       This constraint is defined locally for the relation.  It is a
       non-inheritable constraint.
      </td></tr><tr><td><code class="structfield">conkey</code></td><td><code class="type">int2[]</code></td><td><code class="literal"><a class="link" href="catalog-pg-attribute.html" title="52.7. pg_attribute"><code class="structname">pg_attribute</code></a>.attnum</code></td><td>If a table constraint (including foreign keys, but not constraint
       triggers), list of the constrained columns</td></tr><tr><td><code class="structfield">confkey</code></td><td><code class="type">int2[]</code></td><td><code class="literal"><a class="link" href="catalog-pg-attribute.html" title="52.7. pg_attribute"><code class="structname">pg_attribute</code></a>.attnum</code></td><td>If a foreign key, list of the referenced columns</td></tr><tr><td><code class="structfield">conpfeqop</code></td><td><code class="type">oid[]</code></td><td><code class="literal"><a class="link" href="catalog-pg-operator.html" title="52.34. pg_operator"><code class="structname">pg_operator</code></a>.oid</code></td><td>If a foreign key, list of the equality operators for PK = FK comparisons</td></tr><tr><td><code class="structfield">conppeqop</code></td><td><code class="type">oid[]</code></td><td><code class="literal"><a class="link" href="catalog-pg-operator.html" title="52.34. pg_operator"><code class="structname">pg_operator</code></a>.oid</code></td><td>If a foreign key, list of the equality operators for PK = PK comparisons</td></tr><tr><td><code class="structfield">conffeqop</code></td><td><code class="type">oid[]</code></td><td><code class="literal"><a class="link" href="catalog-pg-operator.html" title="52.34. pg_operator"><code class="structname">pg_operator</code></a>.oid</code></td><td>If a foreign key, list of the equality operators for FK = FK comparisons</td></tr><tr><td><code class="structfield">conexclop</code></td><td><code class="type">oid[]</code></td><td><code class="literal"><a class="link" href="catalog-pg-operator.html" title="52.34. pg_operator"><code class="structname">pg_operator</code></a>.oid</code></td><td>If an exclusion constraint, list of the per-column exclusion operators</td></tr><tr><td><code class="structfield">conbin</code></td><td><code class="type">pg_node_tree</code></td><td> </td><td>If a check constraint, an internal representation of the expression</td></tr><tr><td><code class="structfield">consrc</code></td><td><code class="type">text</code></td><td> </td><td>If a check constraint, a human-readable representation of the expression</td></tr></tbody></table></div></div><br class="table-break" /><p>
   In the case of an exclusion constraint, <code class="structfield">conkey</code>
   is only useful for constraint elements that are simple column references.
   For other cases, a zero appears in <code class="structfield">conkey</code>
   and the associated index must be consulted to discover the expression
   that is constrained.  (<code class="structfield">conkey</code> thus has the
   same contents as <code class="structname">pg_index</code>.<code class="structfield">indkey</code> for the
   index.)
  </p><div class="note"><h3 class="title">Note</h3><p>
    <code class="structfield">consrc</code> is not updated when referenced objects
    change; for example, it won't track renaming of columns.  Rather than
    relying on this field, it's best to use <code class="function">pg_get_constraintdef()</code>
    to extract the definition of a check constraint.
   </p></div><div class="note"><h3 class="title">Note</h3><p>
    <code class="literal">pg_class.relchecks</code> needs to agree with the
    number of check-constraint entries found in this table for each
    relation.
   </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="catalog-pg-collation.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="catalogs.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="catalog-pg-conversion.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">52.12. <code class="structname">pg_collation</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 52.14. <code class="structname">pg_conversion</code></td></tr></table></div></body></html>