Home Explore Blog CI



postgresql

17th chunk of `doc/src/sgml/ref/alter_table.sgml`
bece75e1c57b3a3a121d8bc5400afcc2d2d512e2c61b0da80000000100000fa0
 its type.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-altertable-desc-owner-to">
    <term><literal>OWNER TO</literal></term>
    <listitem>
     <para>
      This form changes the owner of the table, sequence, view, materialized view,
      or foreign table to the specified user.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-altertable-replica-identity">
    <term><literal>REPLICA IDENTITY</literal></term>
    <listitem>
     <para>
      This form changes the information which is written to the write-ahead log
      to identify rows which are updated or deleted.
      In most cases, the old value of each column is only logged if it differs
      from the new value; however, if the old value is stored externally, it is
      always logged regardless of whether it changed.
      This option has no effect except when logical replication is in use.
     <variablelist>
      <varlistentry id="sql-altertable-replica-identity-default">
       <term><literal>DEFAULT</literal></term>
       <listitem>
        <para>
         Records the old values of the columns of the primary key.
         This is the default for non-system tables.
         When there is no primary key, the behavior is the same as <literal>NOTHING</literal>.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="sql-altertable-replica-identity-using-index">
       <term><literal>USING INDEX <replaceable class="parameter">index_name</replaceable></literal></term>
       <listitem>
        <para>
         Records the old values of the columns covered by the named index,
         that must be unique, not partial, not deferrable, and include only
         columns marked <literal>NOT NULL</literal>. If this index is
         dropped, the behavior is the same as <literal>NOTHING</literal>.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="sql-altertable-replica-identity-full">
       <term><literal>FULL</literal></term>
       <listitem>
        <para>
         Records the old values of all columns in the row.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry id="sql-altertable-replica-identity-nothing">
       <term><literal>NOTHING</literal></term>
       <listitem>
        <para>
         Records no information about the old row. This is the default for
         system tables.
        </para>
       </listitem>
      </varlistentry>
     </variablelist></para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-altertable-desc-rename">
    <term><literal>RENAME</literal></term>
    <listitem>
     <para>
      The <literal>RENAME</literal> forms change the name of a table
      (or an index, sequence, view, materialized view, or foreign table), the
      name of an individual column in a table, or the name of a constraint of
      the table.  When renaming a constraint that has an underlying index,
      the index is renamed as well.
      There is no effect on the stored data.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-altertable-desc-set-schema">
    <term><literal>SET SCHEMA</literal></term>
    <listitem>
     <para>
      This form moves the table into another schema.  Associated indexes,
      constraints, and sequences owned by table columns are moved as well.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-altertable-attach-partition">
    <term><literal>ATTACH PARTITION <replaceable class="parameter">partition_name</replaceable> { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }</literal></term>
    <listitem>
     <para>
      This form attaches an existing table (which might itself be partitioned)
      as a partition of the target table. The table can be attached
      as a partition for specific values using <literal>FOR VALUES</literal>
      or as a default partition by using <literal>DEFAULT</literal>.
   

Title: ALTER TABLE: Ownership, Replica Identity, Renaming, Schema Changes, and Attaching Partitions
Summary
This section describes the ALTER TABLE options for: changing table ownership; configuring replica identity (how rows are identified in the write-ahead log for logical replication, including DEFAULT, USING INDEX, FULL, and NOTHING options); renaming tables, indexes, columns, or constraints; moving a table to a different schema; and attaching an existing table as a partition to the target table.