Home Explore Blog CI



postgresql

32th chunk of `doc/src/sgml/ref/create_table.sgml`
e368190eb3d1ce2e3eeac20b6b6fb6e5717c62c9020a6ad10000000100000fab
 <literal>toast.log_autovacuum_min_duration</literal> (<type>integer</type>)
    <indexterm>
     <primary><varname>log_autovacuum_min_duration</varname></primary>
     <secondary>storage parameter</secondary>
    </indexterm>
    </term>
    <listitem>
     <para>
      Per-table value for <xref linkend="guc-log-autovacuum-min-duration"/>
      parameter.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="reloption-vacuum-max-eager-freeze-failure-rate" xreflabel="vacuum_max_eager_freeze_failure_rate">
    <term><literal>vacuum_max_eager_freeze_failure_rate</literal>, <literal>toast.vacuum_max_eager_freeze_failure_rate</literal> (<type>floating point</type>)
    <indexterm>
     <primary><varname>vacuum_max_eager_freeze_failure_rate</varname></primary>
     <secondary>storage parameter</secondary>
    </indexterm>
    </term>
    <listitem>
     <para>
      Per-table value for <xref linkend="guc-vacuum-max-eager-freeze-failure-rate"/>
      parameter.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="reloption-user-catalog-table" xreflabel="user_catalog_table">
    <term><literal>user_catalog_table</literal> (<type>boolean</type>)
    <indexterm>
     <primary><varname>user_catalog_table</varname> storage parameter</primary>
    </indexterm>
    </term>
    <listitem>
     <para>
      Declare the table as an additional catalog table for purposes of
      logical replication. See
      <xref linkend="logicaldecoding-capabilities"/> for details.
      This parameter cannot be set for TOAST tables.
     </para>
    </listitem>
   </varlistentry>

   </variablelist>

  </refsect2>
 </refsect1>

 <refsect1 id="sql-createtable-notes">
  <title>Notes</title>
    <para>
     <productname>PostgreSQL</productname> automatically creates an
     index for each unique constraint and primary key constraint to
     enforce uniqueness.  Thus, it is not necessary to create an
     index explicitly for primary key columns.  (See <xref
     linkend="sql-createindex"/> for more information.)
    </para>

    <para>
     Unique constraints and primary keys are not inherited in the
     current implementation.  This makes the combination of
     inheritance and unique constraints rather dysfunctional.
    </para>

    <para>
     A table cannot have more than 1600 columns.  (In practice, the
     effective limit is usually lower because of tuple-length constraints.)
    </para>

 </refsect1>


 <refsect1 id="sql-createtable-examples">
  <title>Examples</title>

  <para>
   Create table <structname>films</structname> and table
   <structname>distributors</structname>:

<programlisting>
CREATE TABLE films (
    code        char(5) CONSTRAINT firstkey PRIMARY KEY,
    title       varchar(40) NOT NULL,
    did         integer NOT NULL,
    date_prod   date,
    kind        varchar(10),
    len         interval hour to minute
);

CREATE TABLE distributors (
     did    integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
     name   varchar(40) NOT NULL CHECK (name &lt;&gt; '')
);
</programlisting>
  </para>

  <para>
   Create a table with a 2-dimensional array:

<programlisting>
CREATE TABLE array_int (
    vector  int[][]
);
</programlisting>
  </para>

  <para>
   Define a unique table constraint for the table
   <literal>films</literal>.  Unique table constraints can be defined
   on one or more columns of the table:

<programlisting>
CREATE TABLE films (
    code        char(5),
    title       varchar(40),
    did         integer,
    date_prod   date,
    kind        varchar(10),
    len         interval hour to minute,
    CONSTRAINT production UNIQUE(date_prod)
);
</programlisting>
  </para>

  <para>
   Define a check column constraint:

<programlisting>
CREATE TABLE distributors (
    did     integer CHECK (did &gt; 100),
    name    varchar(40)
);
</programlisting>
  </para>

  <para>
   Define a check table constraint:

<programlisting>
CREATE TABLE distributors (
    did     integer,
    name    varchar(40),

Title: CREATE TABLE Storage Parameters: User Catalog Table, Notes, and Examples
Summary
This section details the 'user_catalog_table' storage parameter, which declares a table as an additional catalog table for logical replication. It also includes notes on automatic index creation for unique and primary key constraints, limitations on inheritance of these constraints, and maximum column limits. The section concludes with examples of creating tables with various constraints, including primary keys, unique constraints, check constraints, and arrays.