head	1.41;
access;
symbols
	REL9_0_0:1.41
	REL9_1_ALPHA1:1.41
	REL9_0_RC1:1.41
	REL9_0_BETA4:1.41
	REL9_0_STABLE:1.41.0.2
	REL9_0_BETA3:1.41
	REL9_0_BETA2:1.41
	REL7_4_29:1.16
	REL8_0_25:1.29
	REL8_1_21:1.31
	REL8_2_17:1.36
	REL8_3_11:1.37
	REL8_4_4:1.40
	REL9_0_BETA1:1.41
	REL9_0_ALPHA5_BRANCH:1.40.0.12
	REL9_0_ALPHA5:1.40
	REL7_4_28:1.16
	REL8_0_24:1.29
	REL8_1_20:1.31
	REL8_2_16:1.36
	REL8_3_10:1.37
	REL8_4_3:1.40
	REL9_0_ALPHA4:1.40
	REL9_0_ALPHA4_BRANCH:1.40.0.10
	REL8_5_ALPHA3:1.40
	REL8_5_ALPHA3_BRANCH:1.40.0.8
	REL7_4_27:1.16
	REL8_0_23:1.29
	REL8_1_19:1.31
	REL8_2_15:1.36
	REL8_3_9:1.37
	REL8_4_2:1.40
	REL8_5_ALPHA2:1.40
	REL8_5_ALPHA2_BRANCH:1.40.0.6
	REL7_4_26:1.16
	REL8_0_22:1.29
	REL8_1_18:1.31
	REL8_2_14:1.36
	REL8_3_8:1.37
	REL8_4_1:1.40
	REL8_5_ALPHA1:1.40
	REL8_5_ALPHA1_BRANCH:1.40.0.4
	REL8_4_STABLE:1.40.0.2
	REL8_4_0:1.40
	REL8_4_RC2:1.40
	REL8_4_RC1:1.40
	REL8_4_BETA2:1.40
	REL8_4_BETA1:1.40
	REL7_4_25:1.16
	REL8_0_21:1.29
	REL8_1_17:1.31
	REL8_2_13:1.36
	REL8_3_7:1.37
	REL7_4_24:1.16
	REL8_0_20:1.29
	REL8_1_16:1.31
	REL8_2_12:1.36
	REL8_3_6:1.37
	REL7_4_23:1.16
	REL8_0_19:1.29
	REL8_1_15:1.31
	REL8_2_11:1.36
	REL8_3_5:1.37
	REL7_4_22:1.16
	REL8_0_18:1.29
	REL8_1_14:1.31
	REL8_2_10:1.36
	REL8_3_4:1.37
	REL7_4_21:1.16
	REL8_0_17:1.29
	REL8_1_13:1.31
	REL8_2_9:1.36
	REL8_3_3:1.37
	REL7_4_20:1.16
	REL8_0_16:1.29
	REL8_1_12:1.31
	REL8_2_8:1.36
	REL8_3_2:1.37
	REL8_2_7:1.36
	REL8_3_1:1.37
	REL8_3_STABLE:1.37.0.2
	REL8_3_0:1.37
	REL8_3_RC2:1.37
	REL7_3_21:1.10.2.1
	REL7_4_19:1.16
	REL8_0_15:1.29
	REL8_1_11:1.31
	REL8_2_6:1.36
	REL8_3_RC1:1.37
	REL8_3_BETA4:1.37
	REL8_3_BETA3:1.37
	REL8_3_BETA2:1.37
	REL8_3_BETA1:1.37
	REL7_3_20:1.10.2.1
	REL7_4_18:1.16
	REL8_0_14:1.29
	REL8_1_10:1.31
	REL8_2_5:1.36
	REL7_3_19:1.10.2.1
	REL7_4_17:1.16
	REL8_0_13:1.29
	REL8_1_9:1.31
	REL8_2_4:1.36
	REL8_0_12:1.29
	REL8_1_8:1.31
	REL8_2_3:1.36
	REL7_3_18:1.10.2.1
	REL7_4_16:1.16
	REL8_0_11:1.29
	REL8_1_7:1.31
	REL8_2_2:1.36
	REL8_0_10:1.29
	REL8_1_6:1.31
	REL8_2_1:1.36
	REL7_4_15:1.16
	REL7_3_17:1.10.2.1
	REL8_2_STABLE:1.36.0.2
	REL8_2_0:1.36
	REL8_2_RC1:1.36
	REL8_2_BETA3:1.36
	REL8_2_BETA2:1.36
	REL8_1_5:1.31
	REL8_0_9:1.29
	REL7_4_14:1.16
	REL7_3_16:1.10.2.1
	REL8_2_BETA1:1.36
	REL7_3_15:1.10.2.1
	REL7_4_13:1.16
	REL8_0_8:1.29
	REL8_1_4:1.31
	REL7_3_14:1.10.2.1
	REL7_4_12:1.16
	REL8_0_7:1.29
	REL8_1_3:1.31
	REL7_3_13:1.10.2.1
	REL7_4_11:1.16
	REL8_0_6:1.29
	REL8_1_2:1.31
	REL7_3_12:1.10.2.1
	REL7_4_10:1.16
	REL8_0_5:1.29
	REL8_1_1:1.31
	REL8_1_STABLE:1.31.0.2
	REL8_1_0:1.31
	REL8_1_0RC1:1.30
	REL8_1_0BETA4:1.30
	REL8_1_0BETA3:1.29
	REL7_3_11:1.10.2.1
	REL7_4_9:1.16
	REL8_0_4:1.29
	REL8_1_0BETA2:1.29
	REL8_1_0BETA1:1.29
	REL7_2_8:1.9
	REL7_3_10:1.10.2.1
	REL7_4_8:1.16
	REL8_0_3:1.29
	REL8_0_2:1.29
	REL7_2_7:1.9
	REL7_3_9:1.10.2.1
	REL7_4_7:1.16
	REL8_0_1:1.29
	REL8_0_STABLE:1.29.0.4
	REL8_0_0:1.29.0.2
	REL8_0_0RC5:1.29
	REL8_0_0RC4:1.28
	REL8_0_0RC3:1.26
	REL8_0_0RC2:1.26
	REL8_0_0RC1:1.25
	REL8_0_0BETA5:1.24
	REL8_0_0BETA4:1.24
	REL7_4_6:1.16
	REL7_3_8:1.10.2.1
	REL7_2_6:1.9
	REL8_0_0BETA3:1.24
	REL8_0_0BETA2:1.23
	REL7_2_5:1.9
	REL7_4_5:1.16
	REL7_3_7:1.10.2.1
	REL7_4_4:1.16
	REL8_0_0BETA1:1.22
	REL7_4_3:1.16
	REL7_4_2:1.16
	REL7_3_6:1.10.2.1
	REL7_4_1:1.16
	REL7_3_5:1.10.2.1
	REL7_4:1.16
	REL7_4_RC2:1.16
	REL7_4_STABLE:1.16.0.2
	REL7_4_RC1:1.16
	REL7_4_BETA5:1.16
	REL7_4_BETA4:1.16
	REL7_4_BETA3:1.16
	REL7_4_BETA2:1.14
	WIN32_DEV:1.14.0.2
	REL7_4_BETA1:1.14
	REL7_3_4:1.10.2.1
	REL7_3_2:1.10.2.1
	REL7_2_4:1.9
	REL7_3_STABLE:1.10.0.2
	REL7_2_3:1.9
	REL7_2_STABLE:1.9.0.2
	REL7_2:1.9
	REL7_2_RC2:1.9
	REL7_2_RC1:1.9
	REL7_2_BETA5:1.9
	REL7_2_BETA4:1.9
	REL7_2_BETA3:1.8
	REL7_2_BETA2:1.8
	REL7_2_BETA1:1.8
	REL7_1_2:1.6
	REL7_1_STABLE:1.6.0.2
	REL7_1_BETA:1.3
	REL7_1_BETA3:1.4
	REL7_1_BETA2:1.4
	REL7_1:1.6
	REL7_0_PATCHES:1.3.0.2
	REL7_0:1.3
	REL6_5_PATCHES:1.2.0.2
	REL6_5:1.2;
locks; strict;
comment	@# @;


1.41
date	2010.04.03.07.23.00;	author petere;	state Exp;
branches;
next	1.40;

1.40
date	2008.11.20.14.04.45;	author petere;	state Exp;
branches;
next	1.39;

1.39
date	2008.11.14.10.22.46;	author petere;	state Exp;
branches;
next	1.38;

1.38
date	2008.10.28.14.09.44;	author petere;	state Exp;
branches;
next	1.37;

1.37
date	2007.06.03.17.06.12;	author tgl;	state Exp;
branches;
next	1.36;

1.36
date	2006.09.18.19.54.01;	author tgl;	state Exp;
branches;
next	1.35;

1.35
date	2006.09.16.00.30.17;	author momjian;	state Exp;
branches;
next	1.34;

1.34
date	2006.07.04.18.07.24;	author tgl;	state Exp;
branches;
next	1.33;

1.33
date	2006.07.02.02.23.18;	author momjian;	state Exp;
branches;
next	1.32;

1.32
date	2006.02.19.00.04.26;	author neilc;	state Exp;
branches;
next	1.31;

1.31
date	2005.11.01.21.09.50;	author tgl;	state Exp;
branches;
next	1.30;

1.30
date	2005.10.15.20.12.33;	author neilc;	state Exp;
branches;
next	1.29;

1.29
date	2005.01.09.05.57.45;	author tgl;	state Exp;
branches;
next	1.28;

1.28
date	2005.01.05.14.22.39;	author petere;	state Exp;
branches;
next	1.27;

1.27
date	2005.01.04.00.39.53;	author tgl;	state Exp;
branches;
next	1.26;

1.26
date	2004.12.13.18.05.10;	author petere;	state Exp;
branches;
next	1.25;

1.25
date	2004.11.27.21.27.07;	author petere;	state Exp;
branches;
next	1.24;

1.24
date	2004.09.23.03.43.57;	author neilc;	state Exp;
branches;
next	1.23;

1.23
date	2004.08.24.00.06.51;	author neilc;	state Exp;
branches;
next	1.22;

1.22
date	2004.08.04.21.33.42;	author tgl;	state Exp;
branches;
next	1.21;

1.21
date	2004.03.09.16.57.47;	author neilc;	state Exp;
branches;
next	1.20;

1.20
date	2004.01.10.23.28.44;	author neilc;	state Exp;
branches;
next	1.19;

1.19
date	2003.12.13.23.59.07;	author neilc;	state Exp;
branches;
next	1.18;

1.18
date	2003.12.01.22.07.58;	author momjian;	state Exp;
branches;
next	1.17;

1.17
date	2003.11.29.19.51.38;	author pgsql;	state Exp;
branches;
next	1.16;

1.16
date	2003.09.09.18.28.53;	author tgl;	state Exp;
branches;
next	1.15;

1.15
date	2003.08.31.17.32.22;	author petere;	state Exp;
branches;
next	1.14;

1.14
date	2003.07.01.00.04.31;	author petere;	state Exp;
branches
	1.14.2.1;
next	1.13;

1.13
date	2003.05.04.00.03.55;	author tgl;	state Exp;
branches;
next	1.12;

1.12
date	2003.04.22.10.08.08;	author petere;	state Exp;
branches;
next	1.11;

1.11
date	2002.11.21.23.34.43;	author petere;	state Exp;
branches;
next	1.10;

1.10
date	2002.04.23.02.07.16;	author tgl;	state Exp;
branches
	1.10.2.1;
next	1.9;

1.9
date	2001.12.08.03.24.35;	author thomas;	state Exp;
branches;
next	1.8;

1.8
date	2001.10.22.18.14.47;	author petere;	state Exp;
branches;
next	1.7;

1.7
date	2001.09.03.12.57.49;	author petere;	state Exp;
branches;
next	1.6;

1.6
date	2001.03.20.20.54.41;	author tgl;	state Exp;
branches;
next	1.5;

1.5
date	2001.03.03.22.11.40;	author tgl;	state Exp;
branches;
next	1.4;

1.4
date	2000.12.25.23.15.26;	author petere;	state Exp;
branches;
next	1.3;

1.3
date	99.07.22.15.09.08;	author thomas;	state Exp;
branches;
next	1.2;

1.2
date	99.07.06.17.16.35;	author thomas;	state Exp;
branches;
next	1.1;

1.1
date	99.06.14.07.37.04;	author thomas;	state Exp;
branches;
next	;

1.10.2.1
date	2002.11.21.23.31.57;	author petere;	state Exp;
branches;
next	;

1.14.2.1
date	2003.09.07.04.36.45;	author momjian;	state Exp;
branches;
next	;


desc
@@


1.41
log
@Remove unnecessary xref endterm attributes and title ids

The endterm attribute is mainly useful when the toolchain does not support
automatic link target text generation for a particular situation.  In  the
past, this was required by the man page tools for all reference page links,
but that is no longer the case, and it now actually gets in the way of
proper automatic link text generation.  The only remaining use cases are
currently xrefs to refsects.
@
text
@<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.40 2008/11/20 14:04:45 petere Exp $
PostgreSQL documentation
-->

<refentry id="SQL-CREATETABLEAS">
 <refmeta>
  <refentrytitle>CREATE TABLE AS</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>CREATE TABLE AS</refname>
  <refpurpose>define a new table from the results of a query</refpurpose>
 </refnamediv>

 <indexterm zone="sql-createtableas">
  <primary>CREATE TABLE AS</primary>
 </indexterm>

 <refsynopsisdiv>
<synopsis>
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable>
    [ (<replaceable>column_name</replaceable> [, ...] ) ]
    [ WITH ( <replaceable class="PARAMETER">storage_parameter</replaceable> [= <replaceable class="PARAMETER">value</replaceable>] [, ... ] ) | WITH OIDS | WITHOUT OIDS ]
    [ ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP } ]
    [ TABLESPACE <replaceable class="PARAMETER">tablespace</replaceable> ]
    AS <replaceable>query</replaceable>
    [ WITH [ NO ] DATA ]
</synopsis>
 </refsynopsisdiv>
  
 <refsect1>
  <title>Description</title>

  <para>
   <command>CREATE TABLE AS</command> creates a table and fills it
   with data computed by a <command>SELECT</command> command.
   The table columns have the
   names and data types associated with the output columns of the
   <command>SELECT</command> (except that you can override the column
   names by giving an explicit list of new column names).
  </para>

  <para>
   <command>CREATE TABLE AS</command> bears some resemblance to
   creating a view, but it is really quite different: it creates a new
   table and evaluates the query just once to fill the new table
   initially.  The new table will not track subsequent changes to the
   source tables of the query.  In contrast, a view re-evaluates its
   defining <command>SELECT</command> statement whenever it is
   queried.
  </para>
 </refsect1>

 <refsect1>
  <title>Parameters</title>

  <variablelist>
   <varlistentry>
    <term><literal>GLOBAL</literal> or <literal>LOCAL</literal></term>
    <listitem>
     <para>
      Ignored for compatibility. Refer to <xref
      linkend="sql-createtable"> for
      details.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>

  <variablelist>
   <varlistentry>
    <term><literal>TEMPORARY</> or <literal>TEMP</></term>
    <listitem>
     <para>
      If specified, the table is created as a temporary table.
      Refer to <xref linkend="sql-createtable"> for details.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable>table_name</replaceable></term>
    <listitem>
     <para>
      The name (optionally schema-qualified) of the table to be created.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><replaceable>column_name</replaceable></term>
    <listitem>
     <para>
      The name of a column in the new table.  If column names are not
      provided, they are taken from the output column names of the
      query.  If the table is created from an
      <command>EXECUTE</command> command, a column name list cannot be
      specified.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>WITH ( <replaceable class="PARAMETER">storage_parameter</replaceable> [= <replaceable class="PARAMETER">value</replaceable>] [, ... ] )</literal></term>
    <listitem>
     <para>
      This clause specifies optional storage parameters for the new table;
      see <xref linkend="sql-createtable-storage-parameters"
      endterm="sql-createtable-storage-parameters-title"> for more
      information.  The <literal>WITH</> clause
      can also include <literal>OIDS=TRUE</> (or just <literal>OIDS</>)
      to specify that rows of the new table
      should have OIDs (object identifiers) assigned to them, or
      <literal>OIDS=FALSE</> to specify that the rows should not have OIDs.
      See <xref linkend="sql-createtable"> for more information.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>WITH OIDS</></term>
    <term><literal>WITHOUT OIDS</></term>
    <listitem>
     <para>
      These are obsolescent syntaxes equivalent to <literal>WITH (OIDS)</>
      and <literal>WITH (OIDS=FALSE)</>, respectively.  If you wish to give
      both an <literal>OIDS</> setting and storage parameters, you must use
      the <literal>WITH ( ... )</> syntax; see above.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <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>
        <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>
        <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 <xref
          linkend="sql-truncate"> 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</replaceable></literal></term>
    <listitem>
     <para>
      The <replaceable class="PARAMETER">tablespace</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 <xref linkend="sql-select"
     >, <link linkend="sql-table">TABLE</link>,
      or
      <xref linkend="sql-values"> command,
      or an <xref linkend="sql-execute"> command
      that runs a prepared <command>SELECT</>, <command>TABLE</>, or <command>VALUES</> query.
     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>WITH [ NO ] DATA</></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</> syntax. Furthermore, <command>CREATE
   TABLE AS</command> offers a superset of the functionality offered
   by <command>SELECT INTO</command>.
  </para>

  <para>
   Prior to <productname>PostgreSQL</productname> 8.0, <command>CREATE
   TABLE AS</command> always included OIDs in the table it
   created.  As of <productname>PostgreSQL</productname> 8.0,
   the <command>CREATE TABLE AS</command> command allows the user to
   explicitly specify whether OIDs should be included. If the
   presence of OIDs is not explicitly specified,
   the <xref linkend="guc-default-with-oids"> configuration variable is
   used.  As of <productname>PostgreSQL</productname> 8.1,
   this variable is false by default, so the default behavior is not
   identical to pre-8.0 releases.  Applications that
   require OIDs in the table created by <command>CREATE TABLE
   AS</command> should explicitly specify <literal>WITH (OIDS)</literal>
   to ensure proper behavior.
  </para>
 </refsect1>

 <refsect1>
  <title>Examples</title>

  <para>
   Create a new table <literal>films_recent</literal> consisting of only
   recent entries from the table <literal>films</literal>:

<programlisting>
CREATE TABLE films_recent AS
  SELECT * FROM films WHERE date_prod &gt;= '2002-01-01';
</programlisting>
  </para>

  <para>
   To copy a table completely, the short form using
   the <literal>TABLE</literal> command can also be used:

<programlisting>
CREATE TABLE films2 AS
  TABLE films;
</programlisting>
  </para>

  <para>
   Create a new temporary table <literal>films_recent</literal>, consisting of
   only recent entries from the table <literal>films</literal>, using a
   prepared statement.  The new table has OIDs and will be dropped at commit:

<programlisting>
PREPARE recentfilms(date) AS
  SELECT * FROM films WHERE date_prod &gt; $1;
CREATE TEMP TABLE films_recent WITH (OIDS) ON COMMIT DROP AS
  EXECUTE recentfilms('2002-01-01');
</programlisting>
  </para>
 </refsect1>

 <refsect1>
  <title>Compatibility</title>

  <para>
   <command>CREATE TABLE AS</command> conforms to the <acronym>SQL</acronym>
   standard.  The following are nonstandard extensions:

   <itemizedlist spacing="compact">
    <listitem>
     <para>
      The standard requires parentheses around the subquery clause; in
      <productname>PostgreSQL</productname>, these parentheses are
      optional.
     </para>
    </listitem>

    <listitem>
     <para>
      In the standard, the <literal>WITH [ NO ] DATA</literal> clause
      is required; in PostgreSQL it is optional.
     </para>
    </listitem>

    <listitem>
     <para>
      <productname>PostgreSQL</> handles temporary tables in a way
      rather different from the standard; see
      <xref linkend="sql-createtable">
      for details.
     </para>
    </listitem>

    <listitem>
     <para>
      The <literal>WITH</> clause is a <productname>PostgreSQL</productname>
      extension; neither storage parameters nor OIDs are in the standard.
     </para>
    </listitem>

    <listitem>
     <para>
      The <productname>PostgreSQL</productname> concept of tablespaces is not
      part of the standard.  Hence, the clause <literal>TABLESPACE</literal>
      is an extension.
     </para>
    </listitem>
   </itemizedlist>
  </para>
 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-createtable"></member>
   <member><xref linkend="sql-execute"></member>
   <member><xref linkend="sql-select"></member>
   <member><xref linkend="sql-selectinto"></member>
   <member><xref linkend="sql-values"></member>
  </simplelist>
 </refsect1>
 
</refentry>
@


1.40
log
@TABLE command
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.39 2008/11/14 10:22:46 petere Exp $
d8 1
a8 1
  <refentrytitle id="sql-createtableas-title">CREATE TABLE AS</refentrytitle>
d66 1
a66 1
      linkend="sql-createtable" endterm="sql-createtable-title"> for
d79 1
a79 1
      Refer to <xref linkend="sql-createtable" endterm="sql-createtable-title"> for details.
d118 1
a118 2
      See <xref linkend="sql-createtable"
      endterm="sql-createtable-title"> for more information.
d161 1
a161 1
          linkend="sql-truncate" endterm="sql-truncate-title"> is done
d199 1
a199 1
      endterm="sql-select-title">, <link linkend="sql-table">TABLE</link>,
d201 2
a202 2
      <xref linkend="sql-values" endterm="sql-values-title"> command,
      or an <xref linkend="sql-execute" endterm="sql-execute-title"> command
d227 1
a227 1
   linkend="sql-selectinto" endterm="sql-selectinto-title">, but it is
d315 1
a315 1
      <xref linkend="sql-createtable" endterm="sql-createtable-title">
d342 5
a346 5
   <member><xref linkend="sql-createtable" endterm="sql-createtable-title"></member>
   <member><xref linkend="sql-execute" endterm="sql-execute-title"></member>
   <member><xref linkend="sql-select" endterm="sql-select-title"></member>
   <member><xref linkend="sql-selectinto" endterm="sql-selectinto-title"></member>
   <member><xref linkend="sql-values" endterm="sql-values-title"></member>
@


1.39
log
@Set SQL man pages to be section 7 by default, and only transform them to
another section if required by the platform (instead of the old way of
building them in section "l" and always transforming them to the
platform-specific section).

This speeds up the installation on common platforms, and it avoids some
funny business with the man page tools and build process.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.38 2008/10/28 14:09:44 petere Exp $
d199 3
a201 1
      A <xref linkend="sql-select" endterm="sql-select-title"> or
d204 1
a204 1
      that runs a prepared <command>SELECT</> or <command>VALUES</> query.
d266 10
@


1.38
log
@Add WITH [NO] DATA clause to CREATE TABLE AS, per SQL.

Also, since WITH is now a reserved word, simplify the token merging code to
only deal with WITH_TIME.

by Tom Lane and myself
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.37 2007/06/03 17:06:12 tgl Exp $
d9 1
@


1.37
log
@Create a GUC parameter temp_tablespaces that allows selection of the
tablespace(s) in which to store temp tables and temporary files.  This is a
list to allow spreading the load across multiple tablespaces (a random list
element is chosen each time a temp object is to be created).  Temp files are
not stored in per-database pgsql_tmp/ directories anymore, but per-tablespace
directories.

Jaime Casanova and Albert Cervera, with review by Bernd Helmle and Tom Lane.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.36 2006/09/18 19:54:01 tgl Exp $
d29 1
d205 12
d281 1
a281 1
   standard, with the following exceptions:
d294 2
a295 6
      The standard defines a <literal>WITH [ NO ] DATA</literal> clause;
      this is not currently implemented by <productname>PostgreSQL</>.
      The behavior provided by <productname>PostgreSQL</> is equivalent
      to the standard's <literal>WITH DATA</literal> case.
      <literal>WITH NO DATA</literal> can be simulated by appending
      <literal>LIMIT 0</> to the query.
@


1.36
log
@Documentation for VALUES lists.  Joe Conway and Tom Lane
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.35 2006/09/16 00:30:17 momjian Exp $
d187 2
a188 3
      <xref linkend="guc-default-tablespace"> is used, or the database's
      default tablespace if <varname>default_tablespace</> is an empty
      string.
@


1.35
log
@Remove emacs info from footer of SGML files.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.34 2006/07/04 18:07:24 tgl Exp $
d37 2
a38 3
   with data computed by a <command>SELECT</command> command or an
   <command>EXECUTE</command> that runs a prepared
   <command>SELECT</command> command.  The table columns have the
d198 4
a201 6
      A query statement (that is, a <command>SELECT</command> command
      or an <command>EXECUTE</command> command that runs a prepared
      <command>SELECT</command> command).  Refer to <xref
      linkend="sql-select" endterm="sql-select-title"> or <xref
      linkend="sql-execute" endterm="sql-execute-title">,
      respectively, for a description of the allowed syntax.
d326 1
@


1.34
log
@Documentation fixes for FILLFACTOR patch.  Minor other editorialization.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.33 2006/07/02 02:23:18 momjian Exp $
a332 17

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:nil
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
@


1.33
log
@Add FILLFACTOR to CREATE INDEX.

ITAGAKI Takahiro
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.32 2006/02/19 00:04:26 neilc Exp $
d25 1
a25 2
    [ WITH OIDS | WITHOUT OIDS ]
    [ WITH (FILLFACTOR = <replaceable>fillfactor</replaceable>) ]
d106 15
a120 11
    <term><literal>WITH OIDS</literal></term>
    <term><literal>WITHOUT OIDS</literal></term>
     <listitem>
      <para>
       This optional clause specifies whether the table created by
       <command>CREATE TABLE AS</command> should include OIDs. If
       neither form of this clause is specified, the value of the
       <xref linkend="guc-default-with-oids"> configuration parameter is
       used.
      </para>
     </listitem>
d124 2
a125 1
    <term><literal>WITH (FILLFACTOR = <replaceable>fillfactor</replaceable>)</literal></term>
d128 4
a131 1
      This optional clause specifies the table's fillfactor in percentage.
d235 1
a235 1
   AS</command> should explicitly specify <literal>WITH OIDS</literal>
d254 3
a256 4
   Create a new temporary table that will be dropped at commit
   <literal>films_recent</literal> with oids consisting of only
   recent entries from the table <literal>films</literal> using a
   prepared statement:
d261 1
a261 1
CREATE TEMP TABLE films_recent WITH OIDS ON COMMIT DROP AS
d289 2
d296 4
a299 2
      <literal>WITH/WITHOUT OIDS</> is a <productname>PostgreSQL</>
      extension.
d305 2
a306 4
      <productname>PostgreSQL</> handles temporary tables in a way
      rather different from the standard; see
      <xref linkend="sql-createtable" endterm="sql-createtable-title">
      for details.
@


1.32
log
@Add TABLESPACE and ON COMMIT clauses to CREATE TABLE AS. ON COMMIT is
required by the SQL standard, and TABLESPACE is useful functionality.
Patch from Kris Jurka, minor editorialization by Neil Conway.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.31 2005/11/01 21:09:50 tgl Exp $
d26 1
d121 9
@


1.31
log
@Make an editorial pass over the reference pages.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.30 2005/10/15 20:12:33 neilc Exp $
d24 4
a27 1
    [ (<replaceable>column_name</replaceable> [, ...] ) ] [ [ WITH | WITHOUT ] OIDS ]
d120 59
d235 14
a268 7
      The standard defines an <literal>ON COMMIT</literal> clause;
      this is not currently implemented by <productname>PostgreSQL</>.
     </para>
    </listitem>

    <listitem>
     <para>
d291 8
@


1.30
log
@Fix assorted typos in the documentation, and use American spelling
rather than British. Patch from Michael Fuhr.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.29 2005/01/09 05:57:45 tgl Exp $
d23 2
a24 1
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ] [ [ WITH | WITHOUT ] OIDS ]
d147 1
a147 1
   produced.  As of <productname>PostgreSQL</productname> 8.0,
d152 3
a154 2
   used. While this variable currently defaults to true, the default
   value may be changed in the future. Therefore, applications that
d156 2
a157 3
   AS</command> should explicitly specify <literal>WITH
   OIDS</literal> to ensure compatibility with future versions
   of <productname>PostgreSQL</productname>.
d179 2
a180 4
   <command>CREATE TABLE AS</command> is specified by the SQL:2003
   standard. There are some small differences between the definition
   of the command in SQL:2003 and its implementation in
   <productname>PostgreSQL</>:
d200 1
a200 1
      The standard defines a <literal>WITH DATA</literal> clause;
d202 18
@


1.29
log
@Some more small improvements in response to 7.4 interactive docs comments.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.28 2005/01/05 14:22:39 petere Exp $
d146 1
a146 1
   produced.  As of <productname>PostgresSQL</productname> 8.0,
@


1.28
log
@Revert cosmetic synopsis changes that break psql translations.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.27 2005/01/04 00:39:53 tgl Exp $
d161 14
@


1.27
log
@More minor updates and copy-editing.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.26 2004/12/13 18:05:10 petere Exp $
d23 1
a23 2
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable>
    [ (<replaceable>column_name</replaceable> [, ...] ) ] [ [ WITH | WITHOUT ] OIDS ]
@


1.26
log
@Spell checker run
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.25 2004/11/27 21:27:07 petere Exp $
d23 2
a24 1
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ] [ [ WITH | WITHOUT ] OIDS ]
d95 3
a97 3
      query.  If the table is created out of an
      <command>EXECUTE</command> command, a column name list can
      currently not be specified.
d109 1
a109 1
       neither form of this clause if specified, the value of the
d147 1
a147 6
   produced. Furthermore, these OIDs were newly generated: they were
   distinct from the OIDs of any of the rows in the source tables of
   the <command>SELECT</command> or <command>EXECUTE</command>
   statement. Therefore, if <command>CREATE TABLE AS</command> was
   frequently executed, the OID counter would be rapidly
   incremented. As of <productname>PostgresSQL</productname> 8.0,
@


1.25
log
@Update of conformance information to SQL:2003
by Troels Arvin, Simon Riggs, Elein Mustain

Make spelling of SQL standard names uniform.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.24 2004/09/23 03:43:57 neilc Exp $
d139 1
a139 1
   TABLE AS</command> offers a superset of the functionality offerred
d153 2
a154 2
   explicitely specify whether OIDs should be included. If the
   presence of OIDs is not explicitely specified,
d159 1
a159 1
   AS</command> should explicitely specify <literal>WITH
@


1.24
log
@Update CREATE TABLE AS docs to reflect the fact that CREATE TABLE AS was
added to the SQL:2003 standard.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.23 2004/08/24 00:06:51 neilc Exp $
d169 1
a169 1
   <command>CREATE TABLE AS</command> is specified by the SQL2003
d171 1
a171 1
   of the command in SQL2003 and its implementation in
@


1.23
log
@Various minor improvements to the SGML documentation: fix some incorrect
SGML markup, add a "deprecated features" section to the 8.0 release
notes, untabify release.sgml and runtime.sgml, and make some other
minor improvements.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.22 2004/08/04 21:33:42 tgl Exp $
d169 28
a196 5
   This command is modeled after an <productname>Oracle</productname>
   feature.  There is no command with equivalent functionality in
   the SQL standard.  However, a combination of <literal>CREATE
   TABLE</literal> and <literal>INSERT ... SELECT</literal> can
   accomplish the same thing with little more effort.
@


1.22
log
@Label CVS tip as 8.0devel instead of 7.5devel.  Adjust various comments
and documentation to reference 8.0 instead of 7.5.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.21 2004/03/09 16:57:47 neilc Exp $
d14 1
a14 1
  <refpurpose>create a new table from the results of a query</refpurpose>
@


1.21
log
@Refer to GUC variables using <xref> tags rather than <varname> tags,
where appropriate. Add "id" and "xreflabel" tags to the descriptions
of the GUC variables to facilitate this. Also make a few minor docs
cleanups.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.20 2004/01/10 23:28:44 neilc Exp $
d144 1
a144 1
   Prior to <productname>PostgreSQL</productname> 7.5, <command>CREATE
d151 1
a151 1
   incremented. As of <productname>PostgresSQL</productname> 7.5,
@


1.20
log
@Implement "WITH / WITHOID OIDS" clause for CREATE TABLE AS. This is
intended to allow application authors to insulate themselves from
changes to the default value of 'default_with_oids' in future releases
of PostgreSQL.

This patch also fixes a bug in the earlier implementation of the
'default_with_oids' GUC variable: code in gram.y should not examine
the value of GUC variables directly due to synchronization issues.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.19 2003/12/13 23:59:07 neilc Exp $
d109 1
a109 1
       <varname>default_with_oids</varname> configuration parameter is
d155 1
a155 1
   the <varname>default_with_oids</varname> configuration variable is
@


1.19
log
@This patch makes some SGML markup more consistent and makes a small
improvement to the SSL auth docs.
@
text
@d2 1
a2 1
$PostgreSQL: pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.18 2003/12/01 22:07:58 momjian Exp $
d23 1
a23 1
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ]
d102 14
d138 3
a140 1
   the <command>SELECT INTO</command> syntax.
d144 2
a145 2
   Prior to <productname>PostgreSQL</> 7.5, <command>CREATE TABLE
   AS</command> always included OIDs in the table it
d151 11
a161 6
   incremented. As of <productname>PostgreSQL</> 7.5, the inclusion of
   OIDs in the table generated by <command>CREATE TABLE AS</command>
   is controlled by the <varname>default_with_oids</varname>
   configuration variable. This variable currently defaults to true,
   but will likely default to false in a future release of
   <productname>PostgreSQL</>.
@


1.18
log
@This patch adds a new GUC var, "default_with_oids", which follows the
proposal for eventually deprecating OIDs on user tables that I posted
earlier to pgsql-hackers. pg_dump now always specifies WITH OIDS or
WITHOUT OIDS when dumping a table. The documentation has been updated.

Neil Conway
@
text
@d2 1
a2 1
$PostgreSQL: pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.17 2003/11/29 19:51:38 pgsql Exp $
d128 13
a140 11
   Prior to PostgreSQL 7.5, <command>CREATE TABLE AS</command> always
   included OIDs in the table it produced. Furthermore, these OIDs
   were newly generated: they were distinct from the OIDs of any of
   the rows in the source tables of the <command>SELECT</command> or
   <command>EXECUTE</command> statement. Therefore, if <command>CREATE
   TABLE AS</command> was frequently executed, the OID counter would
   be rapidly incremented. As of PostgreSQL 7.5, the inclusion of OIDs
   in the table generated by <command>CREATE TABLE AS</command> is
   controlled by the <varname>default_with_oids</varname> configuration
   variable. This variable currently defaults to true, but will likely
   default to false in a future release of <productname>PostgreSQL</>.
@


1.17
log
@
$Header: -> $PostgreSQL Changes ...
@
text
@d2 1
a2 1
$PostgreSQL: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.16 2003/09/09 18:28:53 tgl Exp $
d54 14
a67 1
   
d121 18
a138 4
   This command is functionally equivalent to <xref
   linkend="sql-selectinto" endterm="sql-selectinto-title">, but it is preferred since it is less
   likely to be confused with other uses of the <command>SELECT
   ... INTO</command> syntax.
a158 1
   <member><xref linkend="sql-createview" endterm="sql-createview-title"></member>
@


1.16
log
@Remove a bunch of content-free Diagnostics sections, as per previous
discussion.  (Still have some work to do editing the remainder.)
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.15 2003/08/31 17:32:22 petere Exp $
@


1.15
log
@Add/edit index entries.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.14 2003/07/01 00:04:31 petere Exp $
a101 12
 </refsect1>

 <refsect1>
  <title>Diagnostics</title>

  <para>
   Refer to <xref linkend="sql-createtable"
   endterm="sql-createtable-title">, <xref linkend="sql-select"
   endterm="sql-select-title">, and <xref linkend="sql-execute"
   endterm="sql-execute-title"> for a summary of possible output
   messages.
  </para>
@


1.14
log
@Change EXECUTE INTO to CREATE TABLE AS EXECUTE.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.13 2003/05/04 00:03:55 tgl Exp $
d16 4
@


1.14.2.1
log
@Update this branch to match CVS head, includes WIN32 improvements.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.15 2003/08/31 17:32:22 petere Exp $
a15 4

 <indexterm zone="sql-createtableas">
  <primary>CREATE TABLE AS</primary>
 </indexterm>
@


1.13
log
@When a TIMESTAMP, TIME, or INTERVAL precision is specified larger than our
implementation limits, do not issue an ERROR; instead issue a NOTICE and use
the max supported value.  Per pgsql-general discussion of 28-Apr, this is
needed to allow easy porting from pre-7.3 releases where the limits were
higher.

Unrelated change in same area: accept GLOBAL TEMP/TEMPORARY as a synonym
for TEMPORARY, as per pgsql-hackers discussion of 15-Apr.  We previously
rejected it, but that was based on a misreading of the spec --- SQL92's
GLOBAL temp tables are really closer to what we have than their LOCAL ones.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.12 2003/04/22 10:08:08 petere Exp $
d29 6
a34 5
   with data computed by a <command>SELECT</command> command.  The
   table columns have the names and data types associated with the
   output columns of the <command>SELECT</command> (except that you
   can override the column names by giving an explicit list of new
   column names).
d77 3
a79 1
      query.
d88 6
a93 4
      A query statement (that is, a <command>SELECT</command>
      command).  Refer to
      <xref linkend="sql-select" endterm="sql-select-title">
      for a description of the allowed syntax.
d104 5
a108 3
   Refer to <xref linkend="sql-createtable" endterm="sql-createtable-title"> and
   <xref linkend="sql-select" endterm="sql-select-title">
   for a summary of possible output messages.
d141 1
@


1.12
log
@More editing of reference pages.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.11 2002/11/21 23:34:43 petere Exp $
d19 1
a19 1
CREATE [ [ LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ]
d52 1
a52 1
    <term><literal>[LOCAL] TEMPORARY</> or <literal>[LOCAL] TEMP</></term>
@


1.11
log
@Fixups for man pages
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.10 2002/04/23 02:07:16 tgl Exp $
d21 1
a21 1
  </synopsis>
d25 2
a26 6
  <refsect1info>
   <date>2001-03-20</date>
  </refsect1info>
  <title>
   Description
  </title>
d74 3
a76 4
      The name of a column in the new table. Multiple column names can
      be specified using a comma-delimited list of column names.  If
      column names are not provided, they are taken from the output
      column names of the query.
d122 1
a122 1
   SQL92 or SQL99.  However, a combination of <literal>CREATE
a124 9
  </para>
 </refsect1>

 <refsect1>
  <title>History</title>

  <para>
   The <command>CREATE TABLE AS</command> command has been available
   since <productname>PostgreSQL</productname> 6.3.
@


1.10
log
@Update SQL-command reference pages for schema features.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.9 2001/12/08 03:24:35 thomas Exp $
d8 1
a8 1
  <refentrytitle>CREATE TABLE AS</refentrytitle>
d60 1
a60 1
      Refer to <xref linkend="sql-createtable"> for details.
d92 1
a92 1
      <xref linkend="sql-select">
d104 2
a105 2
   Refer to <xref linkend="sql-createtable"> and
   <xref linkend="sql-select">
d115 1
a115 1
   linkend="sql-selectinto">, but it is preferred since it is less
d146 4
a149 4
   <member><xref linkend="sql-createtable"></member>
   <member><xref linkend="sql-createview"></member>
   <member><xref linkend="sql-select"></member>
   <member><xref linkend="sql-selectinto"></member>
@


1.10.2.1
log
@Fixups for man pages
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql-server/doc/src/sgml/ref/create_table_as.sgml,v 1.10 2002/04/23 02:07:16 tgl Exp $
d8 1
a8 1
  <refentrytitle id="sql-createtableas-title">CREATE TABLE AS</refentrytitle>
d60 1
a60 1
      Refer to <xref linkend="sql-createtable" endterm="sql-createtable-title"> for details.
d92 1
a92 1
      <xref linkend="sql-select" endterm="sql-select-title">
d104 2
a105 2
   Refer to <xref linkend="sql-createtable" endterm="sql-createtable-title"> and
   <xref linkend="sql-select" endterm="sql-select-title">
d115 1
a115 1
   linkend="sql-selectinto" endterm="sql-selectinto-title">, but it is preferred since it is less
d146 4
a149 4
   <member><xref linkend="sql-createtable" endterm="sql-createtable-title"></member>
   <member><xref linkend="sql-createview" endterm="sql-createview-title"></member>
   <member><xref linkend="sql-select" endterm="sql-select-title"></member>
   <member><xref linkend="sql-selectinto" endterm="sql-selectinto-title"></member>
@


1.9
log
@Use PostgreSQL consistantly throughout docs. Before, usage was split evenly
 between Postgres and PostgreSQL.
@
text
@d2 1
a2 1
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.8 2001/10/22 18:14:47 petere Exp $
d45 2
a46 2
   source tables of the query.  In contrast, a view re-evaluates the
   underlying <command>SELECT</command> statements whenever it is
d60 1
a60 9
      Temporary tables are automatically dropped at the end of a
      session.  Existing persistent tables with the same name are not
      visible to the current session while the temporary table exists.
      Any indexes created on a temporary table are automatically
      temporary as well.
     </para>

     <para>
      The <literal>LOCAL</literal> word is optional.
d69 1
a69 3
      The name of the new table to be created.  This table must not
      already exist.  However, a temporary table can be created that
      has the same name as an existing permanent table.
@


1.8
log
@Make the CREATE TABLE ref page more readable and update some information.
@
text
@d2 2
a3 2
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.7 2001/09/03 12:57:49 petere Exp $
Postgres documentation
@


1.7
log
@Put some kind of grammatical uniformity in the <refpurpose> lines.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.6 2001/03/20 20:54:41 tgl Exp $
d8 1
a8 3
  <refentrytitle id="SQL-CREATETABLEAS-TITLE">
   CREATE TABLE AS
  </refentrytitle>
d11 1
d13 2
a14 6
  <refname>
   CREATE TABLE AS
  </refname>
  <refpurpose>
   create a new table from the results of a query
  </refpurpose>
d16 1
d18 3
a20 6
  <refsynopsisdivinfo>
   <date>2001-03-03</date>
  </refsynopsisdivinfo>
  <synopsis>
CREATE [ TEMPORARY | TEMP ] TABLE <replaceable>table</replaceable> [ (<replaceable>column</replaceable> [, ...] ) ]
     AS <replaceable>select_clause</replaceable>
d22 1
a23 80
  <refsect2>
   <refsect2info>
    <date>1998-09-22</date>
   </refsect2info>
   <title>
    Inputs
   </title>
   <para>
   
   <variablelist>
     <varlistentry>
      <term>TEMPORARY or TEMP</term>
      <listitem>
       <para>
	If specified, the table is created only within this session, and is
	automatically dropped on session exit.
	Existing permanent tables with the same name are not visible
	(in this session) while the temporary table exists.
	Any indexes created on a temporary table are automatically
	temporary as well.
       </para>
      </listitem>
     </varlistentry>

    <varlistentry>
     <term><replaceable>table</replaceable></term>
     <listitem>
      <para>
        The name of the new table to be created.
	This table must not already exist.  However, a temporary table
	can be created that has the same name as an existing permanent
	table.
      </para>
     </listitem>
    </varlistentry>

     <varlistentry>
      <term><replaceable>column</replaceable></term>
      <listitem>
       <para>
	The name of a column. Multiple column names can be specified using
	a comma-delimited list of column names.  If column names are not
	provided, they are taken from the output column names of the
	SELECT query.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><replaceable>select_clause</replaceable></term>
      <listitem>
       <para>
	A valid query statement. Refer to
	<xref linkend="sql-select" endterm="sql-select-title">
	for a description of the allowed syntax.
       </para>
      </listitem>
     </varlistentry>
    </variablelist>
   </para>
  </refsect2>

  <refsect2>
   <refsect2info>
    <date>1998-09-22</date>
   </refsect2info>
   <title>
    Outputs
   </title>

   <para>
    Refer to
    <xref linkend="sql-createtable" endterm="sql-createtable-title">
    and
    <xref linkend="sql-select" endterm="sql-select-title">
    for a summary of possible output messages.
   </para>
  </refsect2>
 </refsynopsisdiv>
 
d34 1
a34 1
   table columns have the names and datatypes associated with the
d36 81
a116 2
   can override the <command>SELECT</command> column names by giving
   an explicit list of column names).
d118 15
d135 5
a139 6
   <command>CREATE TABLE AS</command> bears some resemblance to creating
   a view, but it is really quite different: it creates a new table and
   evaluates the <command>SELECT</command> just once to fill the new table
   initially.  The new table will not track subsequent changes to
   the source tables of the <command>SELECT</command>.  In contrast,
   a view re-evaluates the given <command>SELECT</command> whenever queried.
d141 4
d147 2
a148 4
   This command is functionally equivalent to
   <xref linkend="sql-selectinto" endterm="sql-selectinto-title">,
   but it is preferred since it is less likely to be confused with
   other uses of the <command>SELECT ... INTO</command> syntax.
d151 12
@


1.6
log
@Recommend CREATE TABLE AS in preference to SELECT INTO.  Remove the
(inadequate anyway) mention of SELECT INTO from the main SELECT ref page.
Point out that SELECT INTO means something else in plpgsql and ecpg.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.5 2001/03/03 22:11:40 tgl Exp $
d18 1
a18 1
   Creates a new table from the results of a SELECT
@


1.5
log
@Document TEMP option.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.4 2000/12/25 23:15:26 petere Exp $
d18 1
a18 1
   Creates a new table
d44 1
a44 1
	If specified, the table is created only for this session, and is
d58 4
a61 1
       The name of a new table to be created.
d82 3
a84 2
	A valid query statement. Refer to SELECT for a description of the
	allowed syntax.
d99 1
d101 5
a105 3
    Refer to <command>CREATE TABLE</command>
    and <command>SELECT</command> for a summary of possible output
    messages.
d112 1
a112 1
   <date>1998-09-22</date>
d118 19
a136 3
   <command>CREATE TABLE AS</command> enables a table to be created
   from the contents of an existing table.
   It is functionally equivalent to
d138 2
a139 1
   but with perhaps a more direct syntax.
@


1.4
log
@Refine some things to create better looking man pages.
@
text
@d2 1
a2 1
$Header: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.3 1999/07/22 15:09:08 thomas Exp $
d23 1
a23 1
   <date>1999-07-20</date>
d26 1
a26 1
CREATE TABLE <replaceable>table</replaceable> [ (<replaceable>column</replaceable> [, ...] ) ]
d40 14
d68 3
a70 1
	a comma-delimited list of column names.
d113 1
a113 1
   It is functionality equivalent to
@


1.3
log
@Complete merge of all old man page information.
ecpg reference page still needs formatting.
@
text
@d2 1
a2 1
$Header$
d98 1
a98 1
   <xref linkend="sql-selectinto-title" endterm="sql-selectinto-title">,
@


1.2
log
@Fix markup for docbook2man man page generation.
No big deal; fixed lots of other markup at the same time.
Bigest change: make sure there is no whitespace
 in front of <term> contents.
This will probably help the other output types too.
@
text
@d1 6
a6 1
<refentry id="CREATETABLEAS">
d8 1
a8 1
  <refentrytitle>
d23 1
a23 1
   <date>1998-09-22</date>
d95 4
a98 2
   <command>CREATE TABLE AS</command> enables a table to be created from the contents of
   an existing table. It has functionality equivalent to <command>SELECT TABLE INTO</command>,
@


1.1
log
@Minor updates for release.
Split reference pages for CREATE TABLE AS and SELECT INTO to allow psgml
 (the emacs parser) to handle parsing.
@
text
@d36 1
a36 3
     <term>
      <replaceable>table</replaceable>
     </term>
d45 15
a59 19
     <term>
      <replaceable>column</replaceable>
     </term>
     <listitem>
      <para>
       The name of a column. Multiple column names can be specified using
a comma-delimited list of column names.
      </para>
     </listitem>
    </varlistentry>
    
    <varlistentry>
     <term>
      <replaceable>select_clause</replaceable>
     </term>
     <listitem>
      <para>
A valid query statement. Refer to SELECT for a description of the
allowed syntax.
d75 2
a76 1
    Refer to CREATE TABLE and SELECT for a summary of possible output
d89 4
a92 4
   <para>
CREATE TABLE AS enables a table to be created from the contents of
an existing table. It has functionality equivalent to SELECT TABLE INTO,
but with perhaps a more obvious syntax.
@
