@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.19 2003/12/13 23:59:07 neilc Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table_as.sgml,v 1.20 2004/01/10 23:28:44 neilc Exp $
PostgreSQL documentation
-->
@ -20,7 +20,7 @@ PostgreSQL documentation
<refsynopsisdiv>
<synopsis>
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ]
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name</replaceable> [ (<replaceable>column_name</replaceable> [, ...] ) ] [ [ WITH | WITHOUT ] OIDS ]
AS <replaceable>query</replaceable>
</synopsis>
</refsynopsisdiv>
@ -98,6 +98,20 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name
</listitem>
</varlistentry>
<varlistentry>
<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 if specified, the value of the
<varname>default_with_oids</varname> configuration parameter is
used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable>query</replaceable></term>
<listitem>
@ -121,23 +135,30 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE <replaceable>table_name
This command is functionally similar 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.
the <command>SELECT INTO</> syntax. Furthermore, <command>CREATE
TABLE AS</command> offers a superset of the functionality offerred
by <command>SELECT INTO</command>.
</para>
<para>
Prior to <productname>PostgreSQL</> 7.5, <command>CREATE TABL E
AS</command> always included OIDs in the table it
Prior to <productname>PostgreSQL</productname > 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 <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</>.
incremented. As of <productname>PostgresSQL</productname> 7.5,
the <command>CREATE TABLE AS</command> command allows the user to
explicitely specify whether OIDs should be included. If the
presence of OIDs is not explicitely specified,
the <varname>default_with_oids</varname> configuration variable is
used. While this variable currently defaults to true, the default
value may be changed in the future. Therefore, applications that
require OIDs in the table created by <command>CREATE TABLE
AS</command> should explicitely specify <literal>WITH
OIDS</literal> to ensure compatibility with future versions
of <productname>PostgreSQL</productname>.
</para>
</refsect1>