Home Explore Blog CI



postgresql

47th chunk of `doc/src/sgml/information_schema.sgml`
7b3cdcb04fabe05f9130873f33039724e8a8d6a1065fa8eb0000000100000fa1
 </tbody>
   </tgroup>
  </table>
 </sect1>

 <sect1 id="infoschema-referential-constraints">
  <title><literal>referential_constraints</literal></title>

  <para>
   The view <literal>referential_constraints</literal> contains all
   referential (foreign key) constraints in the current database.
   Only those constraints are shown for which the current user has
   write access to the referencing table (by way of being the
   owner or having some privilege other than <literal>SELECT</literal>).
  </para>

  <table>
   <title><structname>referential_constraints</structname> Columns</title>
   <tgroup cols="1">
    <thead>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       Column Type
      </para>
      <para>
       Description
      </para></entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>constraint_catalog</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the database containing the constraint (always the current database)
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>constraint_schema</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the schema containing the constraint
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>constraint_name</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the constraint
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>unique_constraint_catalog</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the database that contains the unique or primary key
       constraint that the foreign key constraint references (always
       the current database)
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>unique_constraint_schema</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the schema that contains the unique or primary key
       constraint that the foreign key constraint references
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>unique_constraint_name</structfield> <type>sql_identifier</type>
      </para>
      <para>
       Name of the unique or primary key constraint that the foreign
       key constraint references
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>match_option</structfield> <type>character_data</type>
      </para>
      <para>
       Match option of the foreign key constraint:
       <literal>FULL</literal>, <literal>PARTIAL</literal>, or
       <literal>NONE</literal>.
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>update_rule</structfield> <type>character_data</type>
      </para>
      <para>
       Update rule of the foreign key constraint:
       <literal>CASCADE</literal>, <literal>SET NULL</literal>,
       <literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>, or
       <literal>NO ACTION</literal>.
      </para></entry>
     </row>

     <row>
      <entry role="catalog_table_entry"><para role="column_definition">
       <structfield>delete_rule</structfield> <type>character_data</type>
      </para>
      <para>
       Delete rule of the foreign key constraint:
       <literal>CASCADE</literal>, <literal>SET NULL</literal>,
       <literal>SET DEFAULT</literal>, <literal>RESTRICT</literal>, or
       <literal>NO ACTION</literal>.
      </para></entry>

Title: Information Schema: Referential Constraints View
Summary
This section describes the 'referential_constraints' view, which contains information about foreign key constraints in the current database, including the constraint name, schema, and database, as well as the referenced unique or primary key constraint and the update and delete rules for the foreign key constraint.