Home Explore Blog CI



postgresql

4th chunk of `doc/src/sgml/ref/alter_type.sgml`
70ca69dab35888a72dd04c712273e1ad1f7a39c2665228170000000100000f9d
 See <xref linkend="sql-altertable"/> to change the TOAST
         strategy for existing table columns.
        </para>
       </listitem>
      </itemizedlist>
      See <xref linkend="sql-createtype"/> for more details about these
      type properties.  Note that where appropriate, a change in these
      properties for a base type will be propagated automatically to domains
      based on that type.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
  </para>

  <para>
   The <literal>ADD ATTRIBUTE</literal>, <literal>DROP
   ATTRIBUTE</literal>, and <literal>ALTER ATTRIBUTE</literal> actions
   can be combined into a list of multiple alterations to apply in
   parallel.  For example, it is possible to add several attributes
   and/or alter the type of several attributes in a single command.
  </para>

  <para>
   You must own the type to use <command>ALTER TYPE</command>.
   To change the schema of a type, you must also have
   <literal>CREATE</literal> privilege on the new schema.
   To alter the owner, you must be able to <literal>SET ROLE</literal> to the
   new owning role, and that role must have <literal>CREATE</literal>
   privilege on the type's schema.
   (These restrictions enforce that altering the owner
   doesn't do anything you couldn't do by dropping and recreating the type.
   However, a superuser can alter ownership of any type anyway.)
   To add an attribute or alter an attribute type, you must also
   have <literal>USAGE</literal> privilege on the attribute's data type.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

   <para>
    <variablelist>
     <varlistentry>
      <term><replaceable class="parameter">name</replaceable></term>
      <listitem>
       <para>
        The name (possibly schema-qualified) of an existing type to
        alter.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">new_name</replaceable></term>
      <listitem>
       <para>
        The new name for the type.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">new_owner</replaceable></term>
      <listitem>
       <para>
        The user name of the new owner of the type.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">new_schema</replaceable></term>
      <listitem>
       <para>
        The new schema for the type.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">attribute_name</replaceable></term>
      <listitem>
       <para>
        The name of the attribute to add, alter, or drop.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">new_attribute_name</replaceable></term>
      <listitem>
       <para>
        The new name of the attribute to be renamed.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">data_type</replaceable></term>
      <listitem>
       <para>
        The data type of the attribute to add, or the new type of the
        attribute to alter.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">new_enum_value</replaceable></term>
      <listitem>
       <para>
        The new value to be added to an enum type's list of values,
        or the new name to be given to an existing value.
        Like all enum literals, it needs to be quoted.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable class="parameter">neighbor_enum_value</replaceable></term>
      <listitem>
       <para>
        The existing enum value that the new value should be added immediately
        before or after in the enum type's sort ordering.
        Like all enum literals, it needs to be

Title: ALTER TYPE Command: Permissions and Parameters
Summary
To use `ALTER TYPE`, you must own the type and have CREATE privileges on the new schema. Changing the owner requires the ability to SET ROLE to the new owner and CREATE privilege on the schema. Superusers can override ownership restrictions. Modifying attributes requires USAGE privilege on the attribute's data type. The section also lists parameters such as type names, owner, schema, attribute names, and data types.