Home Explore Blog CI



postgresql

25th chunk of `doc/src/sgml/ref/create_table.sgml`
e913a7a0d1d6b6623303716fdaab792ccbb3951000f053150000000100000fa0
 id="sql-createtable-parms-without-oids">
    <term><literal>WITHOUT OIDS</literal></term>
    <listitem>
     <para>
      This is backward-compatible syntax for declaring a table
      <literal>WITHOUT OIDS</literal>, creating a table <literal>WITH
      OIDS</literal> is not supported anymore.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-createtable-parms-on-commit">
    <term><literal>ON COMMIT</literal></term>
    <listitem>
     <para>
      The behavior of temporary tables at the end of a transaction
      block can be controlled using <literal>ON COMMIT</literal>.
      The three options are:

      <variablelist>
       <varlistentry id="sql-createtable-parms-on-commit-preserve-rows">
        <term><literal>PRESERVE ROWS</literal></term>
        <listitem>
         <para>
          No special action is taken at the ends of transactions.
          This is the default behavior.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-on-commit-delete-rows">
        <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.  When used on a partitioned table, this
          is not cascaded to its partitions.
         </para>
        </listitem>
       </varlistentry>

       <varlistentry id="sql-createtable-parms-on-commit-drop">
        <term><literal>DROP</literal></term>
        <listitem>
         <para>
          The temporary table will be dropped at the end of the current
          transaction block.  When used on a partitioned table, this action
          drops its partitions and when used on tables with inheritance
          children, it drops the dependent children.
         </para>
        </listitem>
       </varlistentry>
      </variablelist></para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-createtable-tablespace">
    <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.  For
      partitioned tables, since no storage is required for the table itself,
      the tablespace specified overrides <literal>default_tablespace</literal>
      as the default tablespace to use for any newly created partitions when no
      other tablespace is explicitly specified.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry id="sql-createtable-parms-using-index-tablespace">
    <term><literal>USING INDEX TABLESPACE <replaceable class="parameter">tablespace_name</replaceable></literal></term>
    <listitem>
     <para>
      This clause allows selection of the tablespace in which the index
      associated with a <literal>UNIQUE</literal>, <literal>PRIMARY
      KEY</literal>, or <literal>EXCLUDE</literal> constraint will 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>

  </variablelist>

  <refsect2 id="sql-createtable-storage-parameters" xreflabel="Storage Parameters">
   <title>Storage Parameters</title>

 <indexterm zone="sql-createtable-storage-parameters">
  <primary>storage parameters</primary>
 </indexterm>

   <para>
    The <literal>WITH</literal> clause can specify <firstterm>storage parameters</firstterm>
    for tables, and for indexes associated with a <literal>UNIQUE</literal>,
    <literal>PRIMARY

Title: ON COMMIT Options, Tablespaces, and Storage Parameters for CREATE TABLE
Summary
This section details the ON COMMIT options (PRESERVE ROWS, DELETE ROWS, DROP) for temporary tables, explaining their behavior at transaction end. It also describes the TABLESPACE and USING INDEX TABLESPACE clauses for specifying where tables and indexes are stored, respectively. Finally, it introduces storage parameters that can be configured using the WITH clause for both tables and indexes associated with constraints.