Home Explore Blog CI



postgresql

13th chunk of `doc/src/sgml/ref/create_table.sgml`
453878d5b827da4fb325eb534d51649272402a2b7cd757eb0000000100000fa2
 default behavior is to exclude comments, resulting in
          the copied columns and constraints in the new table having no
          comments.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-compression">
        <term><literal>INCLUDING COMPRESSION</literal></term>
        <listitem>
         <para>
          Compression method of the columns will be copied.  The default
          behavior is to exclude compression methods, resulting in columns
          having the default compression method.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-constraints">
        <term><literal>INCLUDING CONSTRAINTS</literal></term>
        <listitem>
         <para>
          <literal>CHECK</literal> constraints will be copied.  No distinction
          is made between column constraints and table constraints.  Not-null
          constraints are always copied to the new table.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-defaults">
        <term><literal>INCLUDING DEFAULTS</literal></term>
        <listitem>
         <para>
          Default expressions for the copied column definitions will be
          copied.  Otherwise, default expressions are not copied, resulting in
          the copied columns in the new table having null defaults.  Note that
          copying defaults that call database-modification functions, such as
          <function>nextval</function>, may create a functional linkage
          between the original and new tables.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-generated">
        <term><literal>INCLUDING GENERATED</literal></term>
        <listitem>
         <para>
          Any generation expressions as well as the stored/virtual choice of
          copied column definitions will be copied.  By default, new columns
          will be regular base columns.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-identity">
        <term><literal>INCLUDING IDENTITY</literal></term>
        <listitem>
         <para>
          Any identity specifications of copied column definitions will be
          copied.  A new sequence is created for each identity column of the
          new table, separate from the sequences associated with the old
          table.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-indexes">
        <term><literal>INCLUDING INDEXES</literal></term>
        <listitem>
         <para>
          Indexes, <literal>PRIMARY KEY</literal>, <literal>UNIQUE</literal>,
          and <literal>EXCLUDE</literal> constraints on the original table
          will be created on the new table.  Names for the new indexes and
          constraints are chosen according to the default rules, regardless of
          how the originals were named.  (This behavior avoids possible
          duplicate-name failures for the new indexes.)
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-statistics">
        <term><literal>INCLUDING STATISTICS</literal></term>
        <listitem>
         <para>
          Extended statistics are copied to the new table.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-like-opt-storage">
        <term><literal>INCLUDING STORAGE</literal></term>
        <listitem>
         <para>
          <literal>STORAGE</literal> settings for the copied column
          definitions will be copied.  The default behavior is to exclude
          <literal>STORAGE</literal> settings, resulting in the copied columns
          in the new table having type-specific default settings.  For more

Title: CREATE TABLE LIKE Clause Options: Comments, Compression, Constraints, Defaults, and More
Summary
This section details the various options available when using the `LIKE` clause in `CREATE TABLE`. It explains whether to include or exclude properties like comments, compression methods, CHECK constraints, default expressions, generated expressions, identity specifications, indexes, statistics, and storage settings from the original table when creating the new table. It notes the behavior of each option, such as creating new sequences for identity columns or using default naming rules for new indexes, and highlights potential linkages created by copying defaults that call database-modification functions.