Home Explore Blog CI



postgresql

2nd chunk of `doc/src/sgml/ref/alter_foreign_table.sgml`
90e5c29683f5e4613f2e7ccdc0d218e7106d368b2b3075870000000100000fa6
 class="parameter">column_name</replaceable> OPTIONS ( [ ADD | SET | DROP ] <replaceable class="parameter">option</replaceable> ['<replaceable class="parameter">value</replaceable>'] [, ... ])
    ADD <replaceable class="parameter">table_constraint</replaceable> [ NOT VALID ]
    VALIDATE CONSTRAINT <replaceable class="parameter">constraint_name</replaceable>
    DROP CONSTRAINT [ IF EXISTS ]  <replaceable class="parameter">constraint_name</replaceable> [ RESTRICT | CASCADE ]
    DISABLE TRIGGER [ <replaceable class="parameter">trigger_name</replaceable> | ALL | USER ]
    ENABLE TRIGGER [ <replaceable class="parameter">trigger_name</replaceable> | ALL | USER ]
    ENABLE REPLICA TRIGGER <replaceable class="parameter">trigger_name</replaceable>
    ENABLE ALWAYS TRIGGER <replaceable class="parameter">trigger_name</replaceable>
    SET WITHOUT OIDS
    INHERIT <replaceable class="parameter">parent_table</replaceable>
    NO INHERIT <replaceable class="parameter">parent_table</replaceable>
    OWNER TO { <replaceable class="parameter">new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
    OPTIONS ( [ ADD | SET | DROP ] <replaceable class="parameter">option</replaceable> ['<replaceable class="parameter">value</replaceable>'] [, ... ])
</synopsis>
 </refsynopsisdiv>

 <refsect1>
  <title>Description</title>

  <para>
   <command>ALTER FOREIGN TABLE</command> changes the definition of an
   existing foreign table.  There are several subforms:

  <variablelist>
   <varlistentry>
    <term><literal>ADD COLUMN</literal></term>
    <listitem>
     <para>
      This form adds a new column to the foreign table, using the same syntax as
      <link linkend="sql-createforeigntable"><command>CREATE FOREIGN TABLE</command></link>.
      Unlike the case when adding a column to a regular table, nothing happens
      to the underlying storage: this action simply declares that
      some new column is now accessible through the foreign table.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>DROP COLUMN [ IF EXISTS ]</literal></term>
    <listitem>
     <para>
      This form drops a column from a foreign table.
      You will need to say <literal>CASCADE</literal> if
      anything outside the table depends on the column; for example,
      views.
      If <literal>IF EXISTS</literal> is specified and the column
      does not exist, no error is thrown. In this case a notice
      is issued instead.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>SET DATA TYPE</literal></term>
    <listitem>
     <para>
      This form changes the type of a column of a foreign table.
      Again, this has no effect on any underlying storage: this action simply
      changes the type that <productname>PostgreSQL</productname> believes the column to
      have.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>SET</literal>/<literal>DROP DEFAULT</literal></term>
    <listitem>
     <para>
      These forms set or remove the default value for a column.
      Default values only apply in subsequent <command>INSERT</command>
      or <command>UPDATE</command> commands; they do not cause rows already in the
      table to change.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>SET</literal>/<literal>DROP NOT NULL</literal></term>
    <listitem>
     <para>
      Mark a column as allowing, or not allowing, null values.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>SET STATISTICS</literal></term>
    <listitem>
     <para>
      This form
      sets the per-column statistics-gathering target for subsequent
      <link linkend="sql-analyze"><command>ANALYZE</command></link> operations.
      See the similar form of <link linkend="sql-altertable"><command>ALTER TABLE</command></link>
      for more details.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>

Title: ALTER FOREIGN TABLE - Description
Summary
This section describes the different subforms of the ALTER FOREIGN TABLE command, which include adding, dropping, and modifying columns (data type, default values, NOT NULL constraints), setting statistics gathering targets, and managing column options.