Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/create_foreign_table.sgml`
aa9946d1d9a80ee2960c5a690ae9fa90be272a0393df440d0000000100000fa0
  <term><replaceable class="parameter">data_type</replaceable></term>
    <listitem>
     <para>
      The data type of the column. This can include array
      specifiers. For more information on the data types supported by
      <productname>PostgreSQL</productname>, refer to <xref
      linkend="datatype"/>.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>COLLATE <replaceable>collation</replaceable></literal></term>
    <listitem>
     <para>
      The <literal>COLLATE</literal> clause assigns a collation to
      the column (which must be of a collatable data type).
      If not specified, the column data type's default collation is used.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>INHERITS ( <replaceable>parent_table</replaceable> [, ... ] )</literal></term>
    <listitem>
     <para>
      The optional <literal>INHERITS</literal> clause specifies a list of
      tables from which the new foreign table automatically inherits
      all columns.  Parent tables can be plain tables or foreign tables.
      See the similar form of
      <link linkend="sql-createtable"><command>CREATE TABLE</command></link> for more details.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>PARTITION OF <replaceable>parent_table</replaceable> { FOR VALUES <replaceable class="parameter">partition_bound_spec</replaceable> | DEFAULT }</literal></term>
    <listitem>
     <para>
      This form can be used to create the foreign table as partition of
      the given parent table with specified partition bound values.
      See the similar form of
      <link linkend="sql-createtable"><command>CREATE TABLE</command></link> for more details.
      Note that it is currently not allowed to create the foreign table as a
      partition of the parent table if there are <literal>UNIQUE</literal>
      indexes on the parent table.  (See also
      <link linkend="sql-altertable"><command>ALTER TABLE ATTACH PARTITION</command></link>.)
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>LIKE <replaceable>source_table</replaceable> [ <replaceable>like_option</replaceable> ... ]</literal></term>
    <listitem>
     <para>
      The <literal>LIKE</literal> clause specifies a table from which
      the new table automatically copies all column names, their data types,
      and their not-null constraints.
     </para>
     <para>
      Unlike <literal>INHERITS</literal>, the new table and original table
      are completely decoupled after creation is complete.  Changes to the
      original table will not be applied to the new table, and it is not
      possible to include data of the new table in scans of the original
      table.
     </para>
      <para>
      Also unlike <literal>INHERITS</literal>, columns and
      constraints copied by <literal>LIKE</literal> are not merged with similarly
      named columns and constraints.
      If the same name is specified explicitly or in another
      <literal>LIKE</literal> clause, an error is signaled.
     </para>
     <para>
      The optional <replaceable>like_option</replaceable> clauses specify
      which additional properties of the original table to copy.  Specifying
      <literal>INCLUDING</literal> copies the property, specifying
      <literal>EXCLUDING</literal> omits the property.
      <literal>EXCLUDING</literal> is the default.  If multiple specifications
      are made for the same kind of object, the last one is used.  The
      available options are:

      <variablelist>
       <varlistentry>
        <term><literal>INCLUDING COMMENTS</literal></term>
        <listitem>
         <para>
          Comments for the copied columns, constraints, and indexes will be
          copied.  The default behavior is to exclude comments, resulting in
          the copied columns and constraints in the new table having no
          comments.
         </para>
    

Title: CREATE FOREIGN TABLE: Parameters (Continued)
Summary
This section continues the description of parameters for the `CREATE FOREIGN TABLE` command in PostgreSQL. It explains the `INHERITS` clause, which allows the new foreign table to inherit columns from parent tables. It also details the `PARTITION OF` clause, used to create the table as a partition of a parent table with specified bounds. Additionally, the section describes the `LIKE` clause, which copies column names, data types, and not-null constraints from a source table, and explains how it differs from `INHERITS`. The `LIKE` clause also supports `INCLUDING` and `EXCLUDING` options to control which properties are copied.