Commit 6d99dbb0 authored by Tom Lane's avatar Tom Lane

Clarify description of our deviation from standard for temp tables,

per suggestion from Mike Sykes.
parent 810e0b98
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.63 2003/03/25 16:15:39 petere Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v 1.64 2003/04/14 15:24:46 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -826,24 +826,32 @@ CREATE TABLE distributors ( ...@@ -826,24 +826,32 @@ CREATE TABLE distributors (
<title>Temporary Tables</title> <title>Temporary Tables</title>
<para> <para>
In addition to the local temporary table, SQL92 also defines a Although the syntax of <literal>CREATE TEMPORARY TABLE</literal>
<literal>CREATE GLOBAL TEMPORARY TABLE</literal> statement. resembles that of SQL92, the effect is not the same. In the standard,
Global temporary tables are also visible to other sessions. temporary tables are associated with modules; a temporary table is created
just once and automatically exists (starting with empty contents) in every
session that uses the module.
<productname>PostgreSQL</productname> does not have modules, and
requires each session to issue its own <literal>CREATE TEMPORARY
TABLE</literal> command for each temporary table to be used.
</para> </para>
<note>
<para> <para>
For temporary tables, there is an optional <literal>ON COMMIT</literal> clause: The spec-mandated behavior of temporary tables is widely ignored.
<synopsis> <productname>PostgreSQL</productname>'s behavior on this point is similar
CREATE { GLOBAL | LOCAL } TEMPORARY TABLE <replaceable class="parameter">table</replaceable> ( <replaceable class="parameter">...</replaceable> ) [ ON COMMIT { DELETE | PRESERVE } ROWS ] to that of several other RDBMSs.
</synopsis> </para>
</note>
The <literal>ON COMMIT</literal> clause specifies whether or not <para>
the temporary table should be emptied of rows whenever The optional <literal>ON COMMIT</literal> clause for temporary tables
<command>COMMIT</command> is executed. If the <literal>ON also resembles SQL92, but has some differences.
COMMIT</> clause is omitted, SQL92 specifies that the default is If the <literal>ON COMMIT</> clause is omitted, SQL92 specifies that the
<literal>ON COMMIT DELETE ROWS</>. However, the behavior of default behavior is <literal>ON COMMIT DELETE ROWS</>. However, the
<productname>PostgreSQL</productname> is always like <literal>ON default behavior in <productname>PostgreSQL</productname> is
COMMIT PRESERVE ROWS</literal>. <literal>ON COMMIT PRESERVE ROWS</literal>. The <literal>ON COMMIT
DROP</literal> option does not exist in SQL92 at all.
</para> </para>
</refsect2> </refsect2>
...@@ -854,7 +862,7 @@ CREATE { GLOBAL | LOCAL } TEMPORARY TABLE <replaceable class="parameter">table</ ...@@ -854,7 +862,7 @@ CREATE { GLOBAL | LOCAL } TEMPORARY TABLE <replaceable class="parameter">table</
The <literal>NULL</> <quote>constraint</quote> (actually a The <literal>NULL</> <quote>constraint</quote> (actually a
non-constraint) is a <productname>PostgreSQL</productname> non-constraint) is a <productname>PostgreSQL</productname>
extension to SQL92 that is included for compatibility with some extension to SQL92 that is included for compatibility with some
other RDBMS (and for symmetry with the <literal>NOT other RDBMSs (and for symmetry with the <literal>NOT
NULL</literal> constraint). Since it is the default for any NULL</literal> constraint). Since it is the default for any
column, its presence is simply noise. column, its presence is simply noise.
</para> </para>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment