Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/create_table_as.sgml`
e8b77c31545c15aa1a0fafc9daa4d9f3ba21993b7d2f92330000000100000aab
 taken at the ends of transactions.
          This is the default behavior.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>DELETE ROWS</literal></term>
        <listitem>
         <para>
          All rows in the temporary table will be deleted at the end
          of each transaction block.  Essentially, an automatic <link
          linkend="sql-truncate"><command>TRUNCATE</command></link> is done
          at each commit.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry>
        <term><literal>DROP</literal></term>
        <listitem>
         <para>
          The temporary table will be dropped at the end of the current
          transaction block.
         </para>
        </listitem>
       </varlistentry>
      </variablelist></para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>TABLESPACE <replaceable class="parameter">tablespace_name</replaceable></literal></term>
    <listitem>
     <para>
      The <replaceable class="parameter">tablespace_name</replaceable> is the name
      of the tablespace in which the new table is to be created.
      If not specified,
      <xref linkend="guc-default-tablespace"/> is consulted, or
      <xref linkend="guc-temp-tablespaces"/> if the table is temporary.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable>query</replaceable></term>
    <listitem>
     <para>
      A <link linkend="sql-select"><command>SELECT</command></link>, <link
      linkend="sql-table"><command>TABLE</command></link>, or <link linkend="sql-values"><command>VALUES</command></link>
      command, or an <link linkend="sql-execute"><command>EXECUTE</command></link> command that runs a
      prepared <command>SELECT</command>, <command>TABLE</command>, or
      <command>VALUES</command> query.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>WITH [ NO ] DATA</literal></term>
    <listitem>
     <para>
      This clause specifies whether or not the data produced by the query
      should be copied into the new table.  If not, only the table structure
      is copied.  The default is to copy the data.
     </para>
    </listitem>
   </varlistentry>

  </variablelist>
 </refsect1>

 <refsect1>
  <title>Notes</title>

  <para>
   This command is functionally similar to <xref
   linkend="sql-selectinto"/>, but it is
   preferred since it is less likely to be confused with other uses of
   the <command>SELECT INTO</command> syntax. Furthermore, <command>CREATE
   TABLE AS</command> offers a superset of the functionality offered
   by <command>SELECT INTO</command>.
  </para>
 </refsect1>

Title: CREATE TABLE AS - Parameters (Continued) and Notes
Summary
This section continues the parameter list for CREATE TABLE AS, covering TABLESPACE for specifying the tablespace, the query used to define the table, and WITH [NO] DATA to control whether data is copied. It also notes that CREATE TABLE AS is preferred over SELECT INTO for its clarity and extended functionality.