Commit 1ac838ed authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Minor updates for release.

Split reference pages for CREATE TABLE AS and SELECT INTO to allow psgml
 (the emacs parser) to handle parsing.
parent 5e84d58e
...@@ -72,6 +72,7 @@ ...@@ -72,6 +72,7 @@
<!entity createRule system "create_rule.sgml"> <!entity createRule system "create_rule.sgml">
<!entity createSequence system "create_sequence.sgml"> <!entity createSequence system "create_sequence.sgml">
<!entity createTable system "create_table.sgml"> <!entity createTable system "create_table.sgml">
<!entity createTableAs system "create_table_as.sgml">
<!entity createTrigger system "create_trigger.sgml"> <!entity createTrigger system "create_trigger.sgml">
<!entity createType system "create_type.sgml"> <!entity createType system "create_type.sgml">
<!entity createUser system "create_user.sgml"> <!entity createUser system "create_user.sgml">
...@@ -104,6 +105,7 @@ ...@@ -104,6 +105,7 @@
<!entity revoke system "revoke.sgml"> <!entity revoke system "revoke.sgml">
<!entity rollback system "rollback.sgml"> <!entity rollback system "rollback.sgml">
<!entity select system "select.sgml"> <!entity select system "select.sgml">
<!entity selectInto system "select_into.sgml">
<!entity set system "set.sgml"> <!entity set system "set.sgml">
<!entity show system "show.sgml"> <!entity show system "show.sgml">
<!entity unlisten system "unlisten.sgml"> <!entity unlisten system "unlisten.sgml">
......
<REFENTRY ID="SQL-ALTERUSER"> <refentry id="SQL-ALTERUSER">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
ALTER USER ALTER USER
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
ALTER USER ALTER USER
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Modifies user account information Modifies user account information
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<synopsis> <synopsis>
ALTER USER <replaceable class="PARAMETER">username</replaceable> ALTER USER <replaceable class="PARAMETER">username</replaceable>
[ WITH PASSWORD <replaceable class="PARAMETER">password</replaceable> ] [ WITH PASSWORD <replaceable class="PARAMETER">password</replaceable> ]
...@@ -26,91 +26,91 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable> ...@@ -26,91 +26,91 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable>
[ VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>' ] [ VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>' ]
</synopsis> </synopsis>
<REFSECT2 ID="R2-SQL-ALTERUSER-1"> <refsect2 id="R2-SQL-ALTERUSER-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
Refer to <command>CREATE USER</command> for a detailed description of each Refer to <command>CREATE USER</command> for a detailed description of each
clause. clause.
</para> </para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER"> username </REPLACEABLE> <replaceable class="PARAMETER"> username </replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The Postgres account name of the user whose details are to be altered. The Postgres account name of the user whose details are to be altered.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER"> password </REPLACEABLE> <replaceable class="PARAMETER"> password </replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The new password to be used for this account. The new password to be used for this account.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER"> groupname </REPLACEABLE> <replaceable class="PARAMETER"> groupname </replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The name of an access group into which this account is to be put. The name of an access group into which this account is to be put.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER"> abstime </REPLACEABLE> <replaceable class="PARAMETER"> abstime </replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The date (and, optionally, the time) The date (and, optionally, the time)
at which this user's access is to be terminated. at which this user's access is to be terminated.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-ALTERUSER-2"> <refsect2 id="R2-SQL-ALTERUSER-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<returnvalue>ALTER USER</returnvalue> <returnvalue>ALTER USER</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Message returned if the alteration was successful. Message returned if the alteration was successful.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<returnvalue>ERROR: alterUser: user "username" does not exist</returnvalue> <returnvalue>ERROR: alterUser: user "username" does not exist</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Error message returned if the user specified doesn't Error message returned if the user specified doesn't
exist. exist.
</para> </para>
...@@ -118,17 +118,17 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable> ...@@ -118,17 +118,17 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-ALTERUSER-1"> <refsect1 id="R1-SQL-ALTERUSER-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
<command>ALTER USER</command> is used to change the attributes of a user's <command>ALTER USER</command> is used to change the attributes of a user's
<productname>Postgres</productname> account. <productname>Postgres</productname> account.
Please note that it is not possible Please note that it is not possible
...@@ -137,21 +137,21 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable> ...@@ -137,21 +137,21 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable>
<productname>Postgres</productname> <productname>Postgres</productname>
user or any user with read and modify permissions on user or any user with read and modify permissions on
"pg_shadow" to alter user passwords. "pg_shadow" to alter user passwords.
</PARA> </para>
<para> <para>
If any of the clauses of the alter user statement are If any of the clauses of the alter user statement are
omitted, the corresponding value in the "pg_shadow" table omitted, the corresponding value in the "pg_shadow" table
is left unchanged. is left unchanged.
</para> </para>
<REFSECT2 ID="R2-SQL-ALTERUSER-3"> <refsect2 id="R2-SQL-ALTERUSER-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
<command>ALTER USER</command> statement <command>ALTER USER</command> statement
is a <productname>Postgres</productname> is a <productname>Postgres</productname>
language extension. language extension.
...@@ -162,37 +162,37 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable> ...@@ -162,37 +162,37 @@ ALTER USER <replaceable class="PARAMETER">username</replaceable>
account. account.
</para> </para>
<para> <para>
In the current release (v6.4), the IN GROUP clause is parsed In the current release (v6.5), the IN GROUP clause is parsed
but has no affect. When it is fully implemented, it is but has no affect. When it is fully implemented, it is
intended to modify the pg_group relation. intended to modify the pg_group relation.
</para> </para>
</REFSECT2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-ALTERUSER-2"> <refsect1 id="R1-SQL-ALTERUSER-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
Change a user password Change a user password
</PARA> </para>
<ProgramListing> <programlisting>
ALTER USER davide WITH PASSWORD hu8jmn3; ALTER USER davide WITH PASSWORD hu8jmn3;
</ProgramListing> </programlisting>
<para> <para>
Change a user's valid until date Change a user's valid until date
</para> </para>
<ProgramListing> <programlisting>
ALTER USER manuel VALID UNTIL 'Jan 31 2030'; ALTER USER manuel VALID UNTIL 'Jan 31 2030';
</ProgramListing> </programlisting>
<para> <para>
Change a user's valid until date, specifying that his Change a user's valid until date, specifying that his
authorisation should expire at midday on 4th May 1998 using authorisation should expire at midday on 4th May 1998 using
the time zone which is one hour ahead of UTC the time zone which is one hour ahead of UTC
</para> </para>
<ProgramListing> <programlisting>
ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1'; ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
</ProgramListing> </programlisting>
<para> <para>
Give a user the ability to create other users and new databases. Give a user the ability to create other users and new databases.
</para> </para>
...@@ -205,36 +205,36 @@ ALTER USER miriam CREATEUSER CREATEDB; ...@@ -205,36 +205,36 @@ ALTER USER miriam CREATEUSER CREATEDB;
<programlisting> <programlisting>
ALTER USER miriam IN GROUP sales, payroll; ALTER USER miriam IN GROUP sales, payroll;
</programlisting> </programlisting>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-ALTERUSER-3"> <refsect1 id="R1-SQL-ALTERUSER-3">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<PARA> <para>
</PARA> </para>
<REFSECT2 ID="R2-SQL-ALTERUSER-4"> <refsect2 id="R2-SQL-ALTERUSER-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
SQL92 SQL92
</TITLE> </title>
<PARA> <para>
There is no <command>ALTER USER</command> statement in There is no <command>ALTER USER</command> statement in
<acronym>SQL92</acronym>. <acronym>SQL92</acronym>.
The standard leaves The standard leaves
the definition of users to the implementation. the definition of users to the implementation.
</PARA> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>
</REFENTRY> </refentry>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag:t sgml-omittag:nil
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
<REFENTRY ID="SQL-BEGINWORK"> <refentry id="SQL-BEGINWORK">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle id="SQL-BEGINWORK-TITLE">
BEGIN WORK BEGIN
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
BEGIN WORK BEGIN
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Begins a transaction in chained mode Begins a transaction in chained mode
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-08</DATE> <date>1999-06-11</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
BEGIN [ WORK | TRANSACTION ] BEGIN [ WORK | TRANSACTION ]
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-BEGINWORK-1"> <refsect2 id="R2-SQL-BEGINWORK-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1999-06-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
None None
</para> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-BEGINWORK-2"> <refsect2 id="R2-SQL-BEGINWORK-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1999-06-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA>
<VARIABLELIST> <para>
<VARLISTENTRY> <variablelist>
<TERM> <varlistentry>
<returnvalue>BEGIN</returnvalue> <term>
</TERM> <returnvalue>BEGIN</returnvalue>
<LISTITEM> </term>
<PARA> <listitem>
This signifies that a new transaction has been started. <para>
</PARA> This signifies that a new transaction has been started.
</LISTITEM> </para>
</VARLISTENTRY> </listitem>
<VARLISTENTRY> </varlistentry>
<TERM> <varlistentry>
<returnvalue>NOTICE: BeginTransactionBlock and not in default state</returnvalue> <term>
</TERM> <returnvalue>NOTICE: BeginTransactionBlock and not in default state</returnvalue>
<LISTITEM> </term>
<PARA> <listitem>
<para>
This indicates that a transaction was already in progress. This indicates that a transaction was already in progress.
The current transaction is not affected. The current transaction is not affected.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-BEGINWORK-1"> <refsect1 id="R1-SQL-BEGINWORK-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-08</DATE> <date>1999-06-11</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<para> <para>
By default, <productname>Postgres</productname> executes transactions By default, <productname>Postgres</productname> executes transactions
in unchained mode (also known as autocommit feature in other DBMSes). in <firstterm>unchained mode</firstterm>
(also known as <quote>autocommit</quote> in other database
systems).
In other words, each user statement is executed in its own transaction In other words, each user statement is executed in its own transaction
and commit is implicit (if execution was successfull). and a commit is implicitly performed at the end of the statement
(if execution was successful, otherwise a rollback is done).
<command>BEGIN</command> initiates a user transaction in chained mode, <command>BEGIN</command> initiates a user transaction in chained mode,
i.e. all user statements after <command>BEGIN</command> command will i.e. all user statements after <command>BEGIN</command> command will
be executed in single transaction untill explicit COMMIT, ROLLBACK be executed in a single transaction until an explicit COMMIT, ROLLBACK
or execution abort. Statements in chained mode are executed much faster, or execution abort. Statements in chained mode are executed much faster,
because of transaction start/commit requires significant CPU and disk because transaction start/commit requires significant CPU and disk
activity. This mode is also required for consistency when changing activity. Execution of multiple statements inside a transaction
one of related tables. is also required for consistency when changing several
related tables.
</para> </para>
<para> <para>
Default transaction isolation level in <productname>Postgres</productname> The default transaction isolation level in
is READ COMMITTED one, when queries inside transaction see only changes <productname>Postgres</productname>
is READ COMMITTED, where queries inside the transaction see only changes
committed before query execution. So, you have to use committed before query execution. So, you have to use
<command>SET TRANSACTION ISOLATION LEVEL SERIALIZABLE</command> <command>SET TRANSACTION ISOLATION LEVEL SERIALIZABLE</command>
command just after BEGIN if you need in better transaction isolation. just after BEGIN if you need more rigorous transaction isolation.
In SERIALIZABLE mode queries will see only changes committed before entire In SERIALIZABLE mode queries will see only changes committed before
transaction began (actually, before execution of first DML statement the entire
in serializable transaction). transaction began (actually, before execution of the first DML statement
in a serializable transaction).
</para> </para>
<para> <para>
If the transaction is committed, <productname>Postgres</productname> If the transaction is committed, <productname>Postgres</productname>
will ensure either that all updates are done or else that none of will ensure either that all updates are done or else that none of
them are done. Transactions have the standard ACID them are done. Transactions have the standard <acronym>ACID</acronym>
(atomic, consistent, isolatable, and durable) property. (atomic, consistent, isolatable, and durable) property.
</para> </para>
<REFSECT2 ID="R2-SQL-BEGINWORK-3"> <refsect2 id="R2-SQL-BEGINWORK-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1999-06-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
The keyword TRANSACTION is just a cosmetic alternative to WORK. The keyword TRANSACTION is just a cosmetic alternative to WORK.
Neither keyword need be specified. Neither keyword need be specified.
</PARA> </para>
<PARA> <para>
Refer to the <command>LOCK</command> statement for further information Refer to the <command>LOCK</command> statement for further information
about locking tables inside a transaction. about locking tables inside a transaction.
</PARA> </para>
<PARA> <para>
Use <command>COMMIT</command> or <command>ROLLBACK</command> Use <xref linkend="SQL-COMMIT-TITLE" endterm="SQL-COMMIT-TITLE">
or
<xref linkend="SQL-ROLLBACK-TITLE" endterm="SQL-ROLLBACK-TITLE">
to terminate a transaction. to terminate a transaction.
</PARA> </para>
</REFSECT2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-BEGINWORK-2"> <refsect1 id="R1-SQL-BEGINWORK-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA>To begin a user transaction:
<ProgramListing> <para>
To begin a user transaction:
<programlisting>
BEGIN WORK; BEGIN WORK;
</ProgramListing> </programlisting>
</para> </para>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-BEGINWORK-3"> <refsect1 id="R1-SQL-BEGINWORK-3">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<PARA> <para>
<command>BEGIN</command> <command>BEGIN</command>
is a <productname>Postgres</productname> language extension. is a <productname>Postgres</productname> language extension.
</para> </para>
<REFSECT2 ID="R2-SQL-BEGINWORK-4"> <refsect2 id="R2-SQL-BEGINWORK-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1999-06-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
SQL92 SQL92
</TITLE> </title>
<PARA> <para>
There is no explicit BEGIN WORK command in <acronym>SQL92</acronym>; There is no explicit BEGIN WORK command in <acronym>SQL92</acronym>;
transaction initiation is always implicit and it terminates either transaction initiation is always implicit and it terminates either
with a COMMIT or with a ROLLBACK statement. with a COMMIT or with a ROLLBACK statement.
</PARA>
<PARA> <note>
<acronym>SQL92</acronym> also requires SERIALIZABLE to be default <para>
Many relational database systems offer an autocommit feature as a
convenience.
</para>
</note>
</para>
<para>
<acronym>SQL92</acronym> also requires SERIALIZABLE to be the default
transaction isolation level. transaction isolation level.
</PARA> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>
</REFENTRY> </refentry>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag:t sgml-omittag:nil
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
&createRule; &createRule;
&createSequence; &createSequence;
&createTable; &createTable;
&createTableAs;
&createTrigger; &createTrigger;
&createType; &createType;
&createUser; &createUser;
...@@ -57,6 +58,7 @@ ...@@ -57,6 +58,7 @@
&revoke; &revoke;
&rollback; &rollback;
&select; &select;
&selectInto;
&set; &set;
&show; &show;
&unlisten; &unlisten;
......
<REFENTRY ID="SQL-COMMIT"> <refentry id="SQL-COMMIT">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle id="SQL-COMMIT-TITLE">
COMMIT COMMIT
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
COMMIT COMMIT
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Commits the current transaction Commits the current transaction
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
COMMIT [ WORK | TRANSACTION ] COMMIT [ WORK | TRANSACTION ]
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-COMMIT-1"> <refsect2 id="R2-SQL-COMMIT-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
None None
</para> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-COMMIT-2"> <refsect2 id="R2-SQL-COMMIT-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<returnvalue>END</returnvalue> <returnvalue>END</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Message returned if the transaction is successfully committed. Message returned if the transaction is successfully committed.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<returnvalue>NOTICE EndTransactionBlock and not inprogress/abort state</returnvalue> <returnvalue>NOTICE EndTransactionBlock and not inprogress/abort state</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
If there is no transaction in progress. If there is no transaction in progress.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-COMMIT-1"> <refsect1 id="R1-SQL-COMMIT-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
<command>COMMIT</command> commits the current transaction. All <command>COMMIT</command> commits the current transaction. All
changes made by the transaction become visible to others changes made by the transaction become visible to others
and are guaranteed to be durable if a crash occurs. and are guaranteed to be durable if a crash occurs.
</PARA> </para>
<REFSECT2 ID="R2-SQL-COMMIT-3"> <refsect2 id="R2-SQL-COMMIT-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
The keywords WORK and TRANSACTION are noise and can be omitted. The keywords WORK and TRANSACTION are noise and can be omitted.
</PARA> </para>
<para> <para>
Use the <command>ROLLBACK</command> statement to abort a transaction. Use <xref linkend="SQL-ROLLBACK-TITLE" endterm="SQL-ROLLBACK-TITLE">
to abort a transaction.
</para> </para>
</REFSECT2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-COMMIT-2"> <refsect1 id="R1-SQL-COMMIT-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
To make all changes permanent: To make all changes permanent:
</PARA> <programlisting>
<ProgramListing>
COMMIT WORK; COMMIT WORK;
</ProgramListing> </programlisting>
</REFSECT1> </para>
</refsect1>
<REFSECT1 ID="R1-SQL-COMMIT-3"> <refsect1 id="R1-SQL-COMMIT-3">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<PARA> <para>
</PARA> </para>
<REFSECT2 ID="R2-SQL-COMMIT-4"> <refsect2 id="R2-SQL-COMMIT-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-08</DATE> <date>1998-09-08</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
SQL92 SQL92
</TITLE> </title>
<PARA> <para>
Full compatibility. Full compatibility.
</PARA> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>
</REFENTRY> </refentry>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag:t sgml-omittag:nil
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
<REFENTRY ID="SQL-CREATEFUNCTION"> <refentry id="SQL-CREATEFUNCTION">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
CREATE FUNCTION CREATE FUNCTION
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
CREATE FUNCTION CREATE FUNCTION
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Defines a new function Defines a new function
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-09</DATE> <date>1998-09-09</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">ftype</replaceable> [, ...] ] ) CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceable class="parameter">ftype</replaceable> [, ...] ] )
RETURNS <replaceable class="parameter">rtype</replaceable> RETURNS <replaceable class="parameter">rtype</replaceable>
AS <replaceable class="parameter">definition</replaceable> AS <replaceable class="parameter">definition</replaceable>
LANGUAGE '<replaceable class="parameter">langname</replaceable>' LANGUAGE '<replaceable class="parameter">langname</replaceable>'
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-1"> <refsect2 id="R2-SQL-CREATEFUNCTION-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-09</DATE> <date>1998-09-09</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">name</replaceable> <replaceable class="parameter">name</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The name of a function to create. The name of a function to create.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">ftype</replaceable> <replaceable class="parameter">ftype</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The data type of function arguments. The data type of function arguments.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">rtype</replaceable> <replaceable class="parameter">rtype</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The return data type. The return data type.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">definition</replaceable> <replaceable class="parameter">definition</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
A string defining the function; the meaning depends on the language. A string defining the function; the meaning depends on the language.
It may be an internal function name, the path to an object file, It may be an internal function name, the path to an object file,
an SQL query, or text in a procedural language. an SQL query, or text in a procedural language.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">langname</replaceable> <replaceable class="parameter">langname</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
may be '<literal>C</literal>', '<literal>sql</literal>', may be '<literal>C</literal>', '<literal>sql</literal>',
'<literal>internal</literal>' '<literal>internal</literal>'
or '<replaceable class="parameter">plname</replaceable>', or '<replaceable class="parameter">plname</replaceable>',
where '<replaceable class="parameter">plname</replaceable>' where '<replaceable class="parameter">plname</replaceable>'
is the name of a created procedural is the name of a created procedural
language. See <command>CREATE LANGUAGE</command> for details. language. See <command>CREATE LANGUAGE</command> for details.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-2"> <refsect2 id="R2-SQL-CREATEFUNCTION-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-09</DATE> <date>1998-09-09</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue>CREATE</ReturnValue> <returnvalue>CREATE</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
This is returned if the command completes successfully. This is returned if the command completes successfully.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-CREATEFUNCTION-1"> <refsect1 id="R1-SQL-CREATEFUNCTION-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-09</DATE> <date>1998-09-09</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
<command>CREATE FUNCTION</command> allows a <command>CREATE FUNCTION</command> allows a
<productname>Postgres</productname> user <productname>Postgres</productname> user
to register a function to register a function
with a database. Subsequently, this user is treated as the with a database. Subsequently, this user is treated as the
owner of the function. owner of the function.
</PARA> </para>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-3"> <refsect2 id="R2-SQL-CREATEFUNCTION-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-09</DATE> <date>1998-09-09</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
Refer to the chapter on functions Refer to the chapter on functions
in the <citetitle>PostgreSQL Programmer's Guide</citetitle> in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
for further information. for further information.
</PARA> </para>
<PARA> <para>
Use <command>DROP FUNCTION</command> Use <command>DROP FUNCTION</command>
to drop user-defined functions. to drop user-defined functions.
</PARA> </para>
<PARA> <para>
<productname>Postgres</productname> allows function "overloading"; <productname>Postgres</productname> allows function "overloading";
that is, the same name can be used for several different functions that is, the same name can be used for several different functions
so long as they have distinct argument types. This facility must be so long as they have distinct argument types. This facility must be
used with caution for INTERNAL and C-language functions, however. used with caution for INTERNAL and C-language functions, however.
</PARA> </para>
<PARA> <para>
Two INTERNAL functions cannot have the same C name without causing Two INTERNAL functions cannot have the same C name without causing
errors at link time. To get around that, give them different C names errors at link time. To get around that, give them different C names
(for example, use the argument types as part of the C names), then (for example, use the argument types as part of the C names), then
specify those names in the AS clause of <command>CREATE FUNCTION</command>. specify those names in the AS clause of <command>CREATE FUNCTION</command>.
If the AS clause is left empty then <command>CREATE FUNCTION</command> If the AS clause is left empty then <command>CREATE FUNCTION</command>
assumes the C name of the function is the same as the SQL name. assumes the C name of the function is the same as the SQL name.
</PARA> </para>
<PARA> <para>
For dynamically-loaded C functions, the SQL name of the function must For dynamically-loaded C functions, the SQL name of the function must
be the same as the C function name, because the AS clause is used to be the same as the C function name, because the AS clause is used to
give the path name of the object file containing the C code. In this give the path name of the object file containing the C code. In this
...@@ -178,18 +178,18 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle> ...@@ -178,18 +178,18 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
ways if there is a conflict of C function names. So, even if it works ways if there is a conflict of C function names. So, even if it works
for you today, you might regret overloading names later when you try for you today, you might regret overloading names later when you try
to run the code somewhere else. to run the code somewhere else.
</PARA> </para>
</REFSECT2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-CREATEFUNCTION-2"> <refsect1 id="R1-SQL-CREATEFUNCTION-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
To create a simple SQL function: To create a simple SQL function:
</PARA> </para>
<ProgramListing> <programlisting>
CREATE FUNCTION one() RETURNS int4 CREATE FUNCTION one() RETURNS int4
AS 'SELECT 1 AS RESULT' AS 'SELECT 1 AS RESULT'
LANGUAGE 'sql'; LANGUAGE 'sql';
...@@ -201,7 +201,7 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle> ...@@ -201,7 +201,7 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
------ ------
1 1
</computeroutput> </computeroutput>
</ProgramListing> </programlisting>
<para> <para>
To create a C function, calling a routine from a user-created To create a C function, calling a routine from a user-created
shared library. This particular routine calculates a check shared library. This particular routine calculates a check
...@@ -211,44 +211,44 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle> ...@@ -211,44 +211,44 @@ in the <citetitle>PostgreSQL Programmer's Guide</citetitle>
<programlisting> <programlisting>
<userinput> <userinput>
CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c'; AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
CREATE TABLE product CREATE TABLE product (
( id char(8) PRIMARY KEY,
id char(8) PRIMARY KEY, eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}')
eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}') REFERENCES brandname(ean_prefix),
REFERENCES brandname(ean_prefix), eancode char(6) CHECK (eancode ~ '[0-9]{6}'),
eancode char(6) CHECK (eancode ~ '[0-9]{6}'), CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode))
CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode)) );
);</userinput> </userinput>
</programlisting> </programlisting>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-CREATEFUNCTION-3"> <refsect1 id="R1-SQL-CREATEFUNCTION-3">
<TITLE> <title>
Bugs Bugs
</TITLE> </title>
<PARA> <para>
A C function cannot return a set of values. A C function cannot return a set of values.
</PARA> </para>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-CREATEFUNCTION-4"> <refsect1 id="R1-SQL-CREATEFUNCTION-4">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<PARA> <para>
<command>CREATE FUNCTION</command> is <command>CREATE FUNCTION</command> is
a <productname>Postgres</productname> language extension. a <productname>Postgres</productname> language extension.
</PARA> </para>
<REFSECT2 ID="R2-SQL-CREATEFUNCTION-4"> <refsect2 id="R2-SQL-CREATEFUNCTION-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-09</DATE> <date>1998-09-09</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
SQL/PSM SQL/PSM
</TITLE> </title>
<para> <para>
<note> <note>
...@@ -264,7 +264,8 @@ has not yet happened, but it is hoped that PSM will ...@@ -264,7 +264,8 @@ has not yet happened, but it is hoped that PSM will
SQL/PSM <command>CREATE FUNCTION</command> has the following syntax: SQL/PSM <command>CREATE FUNCTION</command> has the following syntax:
<synopsis> <synopsis>
CREATE FUNCTION <replaceable class="parameter">name</replaceable> CREATE FUNCTION <replaceable class="parameter">name</replaceable>
( [ [ IN | OUT | INOUT ] <replaceable class="parameter">parm</replaceable> <replaceable class="parameter">type</replaceable> [, ...] ] ) ( [ [ IN | OUT | INOUT ] <replaceable class="parameter">eter</replaceable>eable> <replaceable
class="parameter">type</replaceable> [, ...] ] )
RETURNS <replaceable class="parameter">rtype</replaceable> RETURNS <replaceable class="parameter">rtype</replaceable>
LANGUAGE '<replaceable class="parameter">langname</replaceable>' LANGUAGE '<replaceable class="parameter">langname</replaceable>'
ESPECIFIC <replaceable class="parameter">routine</replaceable> ESPECIFIC <replaceable class="parameter">routine</replaceable>
...@@ -274,12 +275,12 @@ CREATE FUNCTION <replaceable class="parameter">name</replaceable> ...@@ -274,12 +275,12 @@ CREATE FUNCTION <replaceable class="parameter">name</replaceable>
</para> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>
</REFENTRY> </refentry>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag:t sgml-omittag:nil
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
<REFENTRY ID="SQL-CREATETABLE"> <refentry id="SQL-CREATETABLE">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
CREATE TABLE CREATE TABLE
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
CREATE TABLE CREATE TABLE
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Creates a new table Creates a new table
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
CREATE [ TEMP ] TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ( CREATE [ TEMPORARY | TEMP ] TABLE <replaceable class="PARAMETER">table</replaceable> (
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE> <replaceable class="PARAMETER">column</replaceable> <replaceable
[ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> ] class="PARAMETER">type</replaceable>
[<REPLACEABLE>column_constraint_clause</REPLACEABLE> | PRIMARY KEY } [ ... ] ] [ NULL | NOT NULL ] [ UNIQUE ] [ DEFAULT <replaceable
class="PARAMETER">value</replaceable> ]
[<replaceable>column_constraint_clause</replaceable> | PRIMARY KEY } [ ... ] ]
[, ... ] [, ... ]
[, PRIMARY KEY ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ] [, PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] ) ]
[, CHECK ( <REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE> ) ] [, CHECK ( <replaceable class="PARAMETER">condition</replaceable> ) ]
[, <REPLACEABLE>table_constraint_clause</REPLACEABLE> ] [, <replaceable>table_constraint_clause</replaceable> ]
) [ INHERITS ( <REPLACEABLE>inherited_table</REPLACEABLE> [, ...] ) ] ) [ INHERITS ( <replaceable>inherited_table</replaceable> [, ...] ) ]
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-CREATETABLE-1"> <refsect2 id="R2-SQL-CREATETABLE-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
TEMP TEMPORARY
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The table is created only for this session, and is The table is created only for this session, and is
automatically dropped on session exit. automatically dropped on session exit.
Existing permanent tables with the same name are not visible Existing permanent tables with the same name are not visible
while the temporary table exists. while the temporary table exists.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> <replaceable class="PARAMETER">table</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The name of a new table to be created. The name of a new table to be created.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> <replaceable class="PARAMETER">column</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The name of a column. The name of a column.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">type</REPLACEABLE> <replaceable class="PARAMETER">type</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The type of the column. This may include array specifiers. The type of the column. This may include array specifiers.
Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for Refer to the <citetitle>PostgreSQL User's Guide</citetitle> for
further information about data types and arrays. further information about data types and arrays.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> DEFAULT <replaceable class="PARAMETER">value</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
A default value for a column. A default value for a column.
See the DEFAULT clause for more information. See the DEFAULT clause for more information.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE>column_constraint_clause</REPLACEABLE> <replaceable>column_constraint_clause</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The optional column constraint clauses specify a list of integrity The optional column constraint clauses specify a list of integrity
constraints or tests which new or updated entries must satisfy for constraints or tests which new or updated entries must satisfy for
an insert or update operation to succeed. Each constraint an insert or update operation to succeed. Each constraint
must evaluate to a boolean expression. Although <acronym>SQL92</acronym> must evaluate to a boolean expression. Although <acronym>SQL92</acronym>
requires the <REPLACEABLE CLASS="PARAMETER">column_constraint_clause</REPLACEABLE> requires the <replaceable class="PARAMETER">column_constraint_clause</replaceable>
to refer to that column only, <ProductName>Postgres</ProductName> to refer to that column only, <productname>Postgres</productname>
allows multiple columns allows multiple columns
to be referenced within a single column constraint. to be referenced within a single column constraint.
See the column constraint clause for more information. See the column constraint clause for more information.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE>table_constraint_clause</REPLACEABLE> <replaceable>table_constraint_clause</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The optional table CONSTRAINT clause specifies a list of integrity The optional table CONSTRAINT clause specifies a list of integrity
constraints which new or updated entries must satisfy for constraints which new or updated entries must satisfy for
an insert or update operation to succeed. Each constraint an insert or update operation to succeed. Each constraint
must evaluate to a boolean expression. Multiple columns must evaluate to a boolean expression. Multiple columns
may be referenced within a single constraint. may be referenced within a single constraint.
Only one PRIMARY KEY clause may be specified for a table; Only one PRIMARY KEY clause may be specified for a table;
PRIMARY KEY <REPLACEABLE>column</REPLACEABLE> PRIMARY KEY <replaceable>column</replaceable>
(a table constraint) and PRIMARY KEY (a column constraint) are (a table constraint) and PRIMARY KEY (a column constraint) are
mutually exclusive.. mutually exclusive..
See the table constraint clause for more information. See the table constraint clause for more information.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
INHERITS <REPLACEABLE CLASS="PARAMETER">inherited_table</REPLACEABLE> INHERITS <replaceable class="PARAMETER">inherited_table</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The optional INHERITS clause specifies a collection of table The optional INHERITS clause specifies a collection of table
names from which this table automatically inherits all fields. names from which this table automatically inherits all fields.
If any inherited field name appears more than once, If any inherited field name appears more than once,
...@@ -161,116 +163,116 @@ requires the <REPLACEABLE CLASS="PARAMETER">column_constraint_clause</REPLACEABL ...@@ -161,116 +163,116 @@ requires the <REPLACEABLE CLASS="PARAMETER">column_constraint_clause</REPLACEABL
to the conventions of the Common Lisp Object System (CLOS). to the conventions of the Common Lisp Object System (CLOS).
</para> </para>
</note> </note>
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-CREATETABLE-2"> <refsect2 id="R2-SQL-CREATETABLE-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue>CREATE</ReturnValue> <returnvalue>CREATE</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Message returned if table is successfully created. Message returned if table is successfully created.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue>ERROR</ReturnValue> <returnvalue>ERROR</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Message returned if table creation failed. Message returned if table creation failed.
This is usually accompanied by some descriptive text, such as: This is usually accompanied by some descriptive text, such as:
<ProgramListing> <programlisting>
amcreate: "<replaceable class="parameter">table</replaceable>" relation already exists amcreate: "<replaceable class="parameter">table</replaceable>" relation already exists
</ProgramListing> </programlisting>
which occurs at runtime, if the table specified already exists which occurs at runtime, if the table specified already exists
in the database. in the database.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue>ERROR: DEFAULT: type mismatched</ReturnValue> <returnvalue>ERROR: DEFAULT: type mismatched</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
if data type of default value doesn't match the if data type of default value doesn't match the
column definition's data type. column definition's data type.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-CREATETABLE-1"> <refsect1 id="R1-SQL-CREATETABLE-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
<command>CREATE TABLE</command> will enter a new table into the current data <command>CREATE TABLE</command> will enter a new table into the current data
base. The table will be "owned" by the user issuing the base. The table will be "owned" by the user issuing the
command. command.
</para> </para>
<PARA> <para>
The new table is created as a heap with no initial data. The new table is created as a heap with no initial data.
A table can have no more than 1600 columns (realistically, A table can have no more than 1600 columns (realistically,
this is limited by the fact that tuple sizes must this is limited by the fact that tuple sizes must
be less than 8192 bytes), but this limit may be configured be less than 8192 bytes), but this limit may be configured
lower at some sites. A table cannot have the same name as lower at some sites. A table cannot have the same name as
a system catalog table. a system catalog table.
</PARA> </para>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-DEFAULTCLAUSE-1"> <refsect1 id="R1-SQL-DEFAULTCLAUSE-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
DEFAULT Clause DEFAULT Clause
</TITLE> </title>
<PARA> <para>
<SYNOPSIS> <synopsis>
DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> DEFAULT <replaceable class="PARAMETER">value</replaceable>
</SYNOPSIS> </synopsis>
</para> </para>
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-1"> <refsect2 id="R2-SQL-DEFAULTCLAUSE-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">value</replaceable> <replaceable class="parameter">value</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The possible values for the default value expression are: The possible values for the default value expression are:
<itemizedlist> <itemizedlist>
<listitem> <listitem>
...@@ -291,36 +293,36 @@ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> ...@@ -291,36 +293,36 @@ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE>
</itemizedlist> </itemizedlist>
</para> </para>
</listitem> </listitem>
</VARLISTENTRY> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-2"> <refsect2 id="R2-SQL-DEFAULTCLAUSE-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<para> <para>
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-3"> <refsect2 id="R2-SQL-DEFAULTCLAUSE-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
The DEFAULT clause assigns a default data value to a column The DEFAULT clause assigns a default data value to a column
(via a column definition in the CREATE TABLE statement). (via a column definition in the CREATE TABLE statement).
The data type of a default value must match the column definition's The data type of a default value must match the column definition's
data type. data type.
</PARA> </para>
<PARA> <para>
An INSERT operation that includes a column without a specified An INSERT operation that includes a column without a specified
default value will assign the NULL value to the column default value will assign the NULL value to the column
if no explicit data value is provided for it. if no explicit data value is provided for it.
...@@ -330,8 +332,8 @@ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> ...@@ -330,8 +332,8 @@ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE>
or <replaceable class="parameter">user-function</replaceable> means or <replaceable class="parameter">user-function</replaceable> means
that the default that the default
is the value of the specified function at the time of the INSERT. is the value of the specified function at the time of the INSERT.
</PARA> </para>
<PARA> <para>
There are two types of niladic functions: There are two types of niladic functions:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
...@@ -388,7 +390,7 @@ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE> ...@@ -388,7 +390,7 @@ DEFAULT <REPLACEABLE CLASS="PARAMETER">value</REPLACEABLE>
</para> </para>
<para> <para>
In the current release (v6.4), <productname>Postgres</productname> In the current release (v6.5), <productname>Postgres</productname>
evaluates all default expressions at the time the table is defined. evaluates all default expressions at the time the table is defined.
Hence, functions which are "non-cacheable" such as Hence, functions which are "non-cacheable" such as
<function>CURRENT_TIMESTAMP</function> may not produce the desired <function>CURRENT_TIMESTAMP</function> may not produce the desired
...@@ -409,149 +411,151 @@ This forces <productname>Postgres</productname> to consider the constant a strin ...@@ -409,149 +411,151 @@ This forces <productname>Postgres</productname> to consider the constant a strin
type and then to convert the value to <type>timestamp</type> at runtime. type and then to convert the value to <type>timestamp</type> at runtime.
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-DEFAULTCLAUSE-4"> <refsect2 id="R2-SQL-DEFAULTCLAUSE-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
To assign a constant value as the default for the To assign a constant value as the default for the
columns <literal>did</literal> and <literal>number</literal>, columns <literal>did</literal> and <literal>number</literal>,
and a string literal to the column <literal>did</literal>: and a string literal to the column <literal>did</literal>:
<ProgramListing> <programlisting>
CREATE TABLE video_sales ( CREATE TABLE video_sales (
did VARCHAR(40) DEFAULT 'luso films', did VARCHAR(40) DEFAULT 'luso films',
number INTEGER DEFAULT 0, number INTEGER DEFAULT 0,
total CASH DEFAULT '$0.0' total CASH DEFAULT '$0.0'
); );
</ProgramListing> </programlisting>
</para> </para>
<PARA> <para>
To assign an existing sequence To assign an existing sequence
as the default for the column <literal>did</literal>, as the default for the column <literal>did</literal>,
and a literal to the column <literal>name</literal>: and a literal to the column <literal>name</literal>:
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(3) DEFAULT NEXTVAL('serial'), did DECIMAL(3) DEFAULT NEXTVAL('serial'),
name VARCHAR(40) DEFAULT 'luso films' name VARCHAR(40) DEFAULT 'luso films'
); );
</ProgramListing> </programlisting>
</para> </para>
</refsect2> </refsect2>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-COLUMNCONSTRAINT-1"> <refsect1 id="R1-SQL-COLUMNCONSTRAINT-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Column CONSTRAINT Clause Column CONSTRAINT Clause
</TITLE> </title>
<para> <para>
<SYNOPSIS> <synopsis>
[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] { [ NULL | NOT NULL ] | UNIQUE | PRIMARY KEY | CHECK <replaceable class="parameter">constraint</replaceable> } [, ...] [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] { [
</SYNOPSIS> NULL | NOT NULL ] | UNIQUE | PRIMARY KEY | CHECK <replaceable
class="parameter">constraint</replaceable> } [, ...]
</synopsis>
</para> </para>
<REFSECT2 ID="R2-SQL-COLUMNCONSTRAINT-1"> <refsect2 id="R2-SQL-COLUMNCONSTRAINT-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">name</replaceable> <replaceable class="parameter">name</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
An arbitrary name given to the integrity constraint. An arbitrary name given to the integrity constraint.
If <replaceable class="parameter">name</replaceable> is not specified, If <replaceable class="parameter">name</replaceable> is not specified,
it is generated from the table and column names, it is generated from the table and column names,
which should ensure uniqueness for which should ensure uniqueness for
<replaceable class="parameter">name</replaceable>. <replaceable class="parameter">name</replaceable>.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
NULL NULL
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The column is allowed to contain NULL values. This is the default. The column is allowed to contain NULL values. This is the default.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
NOT NULL NOT NULL
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The column is not allowed to contain NULL values. The column is not allowed to contain NULL values.
This is equivalent to the column constraint This is equivalent to the column constraint
CHECK (<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> NOT NULL). CHECK (<replaceable class="PARAMETER">column</replaceable> NOT NULL).
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
UNIQUE UNIQUE
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The column must have unique values. In <ProductName>Postgres</ProductName> The column must have unique values. In <productname>Postgres</productname>
this is enforced by an implicit creation of a unique index on the table. this is enforced by an implicit creation of a unique index on the table.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
PRIMARY KEY PRIMARY KEY
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
This column is a primary key, which implies that uniqueness is This column is a primary key, which implies that uniqueness is
enforced by the system and that other tables may rely on this column enforced by the system and that other tables may rely on this column
as a unique identifier for rows. as a unique identifier for rows.
See PRIMARY KEY for more information. See PRIMARY KEY for more information.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">constraint</replaceable> <replaceable class="parameter">constraint</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The definition of the constraint. The definition of the constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-COLUMNCONSTRAINT-2"> <refsect2 id="R2-SQL-COLUMNCONSTRAINT-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Description Description
</TITLE> </title>
<para> <para>
A Constraint is a named rule: an SQL object which helps define A Constraint is a named rule: an SQL object which helps define
valid sets of values by putting limits on the results of INSERT, valid sets of values by putting limits on the results of INSERT,
...@@ -576,112 +580,110 @@ as a unique identifier for rows. ...@@ -576,112 +580,110 @@ as a unique identifier for rows.
<note> <note>
<para> <para>
<productname>Postgres</productname> does not yet <productname>Postgres</productname> does not yet
(at release 6.4) support (at release 6.5) support
REFERENCES integrity constraints. The parser REFERENCES integrity constraints. The parser
accepts the REFERENCES syntax but ignores the clause. accepts the REFERENCES syntax but ignores the clause.
</para> </para>
</note> </note>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-NOTNULL-1"> <refsect2 id="R2-SQL-NOTNULL-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
NOT NULL Constraint NOT NULL Constraint
</TITLE> </title>
<SYNOPSIS> <synopsis>
[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] NOT NULL [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] NOT NULL
</SYNOPSIS> </synopsis>
<PARA> <para>
The NOT NULL constraint specifies a rule that a column may The NOT NULL constraint specifies a rule that a column may
contain only non-null values. contain only non-null values.
</PARA> This is a column constraint only, and not allowed
<PARA> as a table constraint.
The NOT NULL constraint is a column constraint only, and not allowed </para>
as a table constraint.
</PARA>
<REFSECT3 ID="R3-SQL-NOTNULL-1"> <refsect3 id="R3-SQL-NOTNULL-1">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
</PARA> </para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable>status</replaceable> <replaceable>status</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue>ERROR: ExecAppend: Fail to add null value in not <returnvalue>ERROR: ExecAppend: Fail to add null value in not
null attribute "<replaceable class="parameter">column</replaceable>".</ReturnValue> null attribute "<replaceable class="parameter">column</replaceable>".</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
This error occurs at runtime if one tries to insert a null value This error occurs at runtime if one tries to insert a null value
into a column which has a NOT NULL constraint. into a column which has a NOT NULL constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</refsect3> </refsect3>
<REFSECT3 ID="R3-SQL-NOTNULL-2"> <refsect3 id="R3-SQL-NOTNULL-2">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
Description Description
</title> </title>
<para> <para>
</para> </para>
</refsect3> </refsect3>
<REFSECT3 ID="R3-SQL-NOTNULL-3"> <refsect3 id="R3-SQL-NOTNULL-3">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
Usage Usage
</title> </title>
<PARA> <para>
Define two NOT NULL column constraints on the table Define two NOT NULL column constraints on the table
<classname>distributors</classname>, <classname>distributors</classname>,
one of which being a named constraint: one of which being a named constraint:
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(3) CONSTRAINT no_null NOT NULL, did DECIMAL(3) CONSTRAINT no_null NOT NULL,
name VARCHAR(40) NOT NULL name VARCHAR(40) NOT NULL
); );
</ProgramListing> </programlisting>
</para> </para>
</refsect3> </refsect3>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-UNIQUECLAUSE-1"> <refsect2 id="R2-SQL-UNIQUECLAUSE-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
UNIQUE Constraint UNIQUE Constraint
</TITLE> </title>
<synopsis> <synopsis>
[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] UNIQUE [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] UNIQUE
</SYNOPSIS> </synopsis>
<refsect3> <refsect3>
<title>Inputs</title> <title>Inputs</title>
...@@ -703,17 +705,17 @@ as a table constraint. ...@@ -703,17 +705,17 @@ as a table constraint.
<refsect3> <refsect3>
<title>Outputs</title> <title>Outputs</title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable>status</replaceable> <replaceable>status</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<returnvalue>ERROR: Cannot insert a duplicate key into a unique index.</returnvalue> <returnvalue>ERROR: Cannot insert a duplicate key into a unique index.</returnvalue>
</term> </term>
<listitem> <listitem>
...@@ -736,7 +738,7 @@ as a table constraint. ...@@ -736,7 +738,7 @@ as a table constraint.
Description Description
</title> </title>
<PARA> <para>
The UNIQUE constraint specifies a rule that a group of one or The UNIQUE constraint specifies a rule that a group of one or
more distinct columns of a table may contain only unique values. more distinct columns of a table may contain only unique values.
</para> </para>
...@@ -748,124 +750,125 @@ Description ...@@ -748,124 +750,125 @@ Description
(This deviates from the <acronym>SQL92</acronym> definition, but (This deviates from the <acronym>SQL92</acronym> definition, but
is a more sensible convention. See the section on compatibility is a more sensible convention. See the section on compatibility
for more details.). for more details.).
</PARA> </para>
<PARA> <para>
Each UNIQUE column constraint must name a column that is Each UNIQUE column constraint must name a column that is
different from the set of columns named by any other UNIQUE or different from the set of columns named by any other UNIQUE or
PRIMARY KEY constraint defined for the table. PRIMARY KEY constraint defined for the table.
</PARA> </para>
<Note> <note>
<Para> <para>
<productname>Postgres</productname> automatically creates a unique <productname>Postgres</productname> automatically creates a unique
index for each UNIQUE constraint, to assure index for each UNIQUE constraint, to assure
data integrity. See CREATE INDEX for more information. data integrity. See CREATE INDEX for more information.
</Para> </para>
</Note> </note>
</refsect3> </refsect3>
<REFSECT3 ID="R3-SQL-UNIQUECLAUSE-3"> <refsect3 id="R3-SQL-UNIQUECLAUSE-3">
<TITLE> <title>
Usage Usage
</title> </title>
<PARA> <para>
Defines a UNIQUE column constraint for the table distributors. Defines a UNIQUE column constraint for the table distributors.
UNIQUE column constraints can only be defined on one column UNIQUE column constraints can only be defined on one column
of the table: of the table:
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(3), did DECIMAL(3),
name VARCHAR(40) UNIQUE name VARCHAR(40) UNIQUE
); );
</ProgramListing> </programlisting>
which is equivalent to the following specified as a table constraint: which is equivalent to the following specified as a table constraint:
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(3), did DECIMAL(3),
name VARCHAR(40), name VARCHAR(40),
UNIQUE(name) UNIQUE(name)
); );
</ProgramListing> </programlisting>
</para> </para>
</refsect3> </refsect3>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-CHECK-1"> <refsect2 id="R2-SQL-CHECK-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<title> <title>
The CHECK Constraint The CHECK Constraint
</title> </title>
<SYNOPSIS> <synopsis>
[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] CHECK ( <replaceable>condition</replaceable> [, ...] ) [ CONSTRAINT <replaceable class="parameter">name</replaceable> ] CHECK
</SYNOPSIS> ( <replaceable>condition</replaceable> [, ...] )
</synopsis>
<refsect3 id="R3-SQL-CHECK-1"> <refsect3 id="R3-SQL-CHECK-1">
<title>Inputs</title> <title>Inputs</title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue><replaceable class="parameter">name</replaceable></ReturnValue> <returnvalue><replaceable class="parameter">name</replaceable></returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
An arbitrary name given to a constraint. An arbitrary name given to a constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable>condition</replaceable> <replaceable>condition</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Any valid conditional expression evaluating to a boolean result. Any valid conditional expression evaluating to a boolean result.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</REFSECT3> </refsect3>
<REFSECT3 ID="R3-SQL-CHECK-2"> <refsect3 id="R3-SQL-CHECK-2">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable>status</replaceable> <replaceable>status</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue> <returnvalue>
ERROR: ExecAppend: rejected due to CHECK constraint ERROR: ExecAppend: rejected due to CHECK constraint
"<replaceable class="parameter">table_column</replaceable>". "<replaceable class="parameter">table_column</replaceable>".
</ReturnValue> </returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
This error occurs at runtime if one tries to insert an illegal This error occurs at runtime if one tries to insert an illegal
value into a column subject to a CHECK constraint. value into a column subject to a CHECK constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</REFSECT3> </refsect3>
<refsect3> <refsect3>
<title>Description</title> <title>Description</title>
...@@ -873,42 +876,42 @@ The CHECK Constraint ...@@ -873,42 +876,42 @@ The CHECK Constraint
The CHECK constraint specifies a restriction on allowed values The CHECK constraint specifies a restriction on allowed values
within a column. within a column.
The CHECK constraint is also allowed as a table constraint. The CHECK constraint is also allowed as a table constraint.
</PARA> </para>
<PARA> <para>
The SQL92 CHECK column constraints can only be defined on, and The SQL92 CHECK column constraints can only be defined on, and
refer to, one column of the table. <productname>Postgres</productname> refer to, one column of the table. <productname>Postgres</productname>
does not have does not have
this restriction. this restriction.
</PARA> </para>
</refsect3> </refsect3>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-PRIMARYKEY-1"> <refsect2 id="R2-SQL-PRIMARYKEY-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
PRIMARY KEY Constraint PRIMARY KEY Constraint
</TITLE> </title>
<SYNOPSIS> <synopsis>
[ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> ] PRIMARY KEY [ CONSTRAINT <replaceable class="PARAMETER">name</replaceable> ] PRIMARY KEY
</SYNOPSIS> </synopsis>
<refsect3> <refsect3>
<title>Inputs</title> <title>Inputs</title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> CONSTRAINT <replaceable class="PARAMETER">name</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
An arbitrary name for the constraint. An arbitrary name for the constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</refsect3> </refsect3>
...@@ -923,7 +926,7 @@ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> ...@@ -923,7 +926,7 @@ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE>
<para> <para>
This occurs at run-time if one tries to insert a duplicate value into This occurs at run-time if one tries to insert a duplicate value into
a column subject to a PRIMARY KEY constraint. a column subject to a PRIMARY KEY constraint.
</PARA> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
...@@ -931,104 +934,105 @@ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> ...@@ -931,104 +934,105 @@ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE>
<refsect3> <refsect3>
<title>Description</title> <title>Description</title>
<PARA> <para>
The PRIMARY KEY column constraint specifies that a column of a table The PRIMARY KEY column constraint specifies that a column of a table
may contain only unique may contain only unique
(non-duplicate), non-NULL values. The definition of (non-duplicate), non-NULL values. The definition of
the specified column does not have to include an explicit NOT NULL the specified column does not have to include an explicit NOT NULL
constraint to be included in a PRIMARY KEY constraint. constraint to be included in a PRIMARY KEY constraint.
</PARA> </para>
<PARA> <para>
Only one PRIMARY KEY can be specified for a table. Only one PRIMARY KEY can be specified for a table.
</PARA> </para>
</REFSECT3> </refsect3>
<REFSECT3 ID="R3-SQL-PRIMARYKEY-3"> <refsect3 id="R3-SQL-PRIMARYKEY-3">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
<productname>Postgres</productname> automatically creates <productname>Postgres</productname> automatically creates
a unique index to assure a unique index to assure
data integrity. (See CREATE INDEX statement) data integrity. (See CREATE INDEX statement)
</PARA> </para>
<PARA> <para>
The PRIMARY KEY constraint should name a set of columns that is The PRIMARY KEY constraint should name a set of columns that is
different from other sets of columns named by any UNIQUE constraint different from other sets of columns named by any UNIQUE constraint
defined for the same table, since it will result in duplication defined for the same table, since it will result in duplication
of equivalent indexes and unproductive additional runtime overhead. of equivalent indexes and unproductive additional runtime overhead.
However, <productname>Postgres</productname> does not specifically However, <productname>Postgres</productname> does not specifically
disallow this. disallow this.
</PARA> </para>
</refsect3> </refsect3>
</refsect2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-TABLECONSTRAINT-1"> <refsect1 id="R1-SQL-TABLECONSTRAINT-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Table CONSTRAINT Clause Table CONSTRAINT Clause
</TITLE> </title>
<para> <para>
<SYNOPSIS> <synopsis>
[ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( <replaceable class="parameter">column</replaceable> [, ...] ) [ CONSTRAINT name ] { PRIMARY KEY | UNIQUE } ( <replaceable
class="parameter">column</replaceable> [, ...] )
[ CONSTRAINT name ] CHECK ( <replaceable>constraint</replaceable> ) [ CONSTRAINT name ] CHECK ( <replaceable>constraint</replaceable> )
</SYNOPSIS> </synopsis>
</para> </para>
<REFSECT2 ID="R2-SQL-TABLECONSTRAINT-1"> <refsect2 id="R2-SQL-TABLECONSTRAINT-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<title> <title>
Inputs Inputs
</title> </title>
<para> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
CONSTRAINT <replaceable class="parameter">name</replaceable> CONSTRAINT <replaceable class="parameter">name</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
An arbitrary name given to an integrity constraint. An arbitrary name given to an integrity constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable class="parameter">column</replaceable> [, ...] <replaceable class="parameter">column</replaceable> [, ...]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The column name(s) for which to define a unique index The column name(s) for which to define a unique index
and, for PRIMARY KEY, a NOT NULL constraint. and, for PRIMARY KEY, a NOT NULL constraint.
</PARA> </para>
</LISTITEM> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
CHECK ( <replaceable class="parameter">constraint</replaceable> ) CHECK ( <replaceable class="parameter">constraint</replaceable> )
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
A boolean expression to be evaluated as the constraint. A boolean expression to be evaluated as the constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-TABLECONSTRAINT-2"> <refsect2 id="R2-SQL-TABLECONSTRAINT-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<title> <title>
Outputs Outputs
</title> </title>
...@@ -1039,10 +1043,10 @@ disallow this. ...@@ -1039,10 +1043,10 @@ disallow this.
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-TABLECONSTRAINT-3"> <refsect2 id="R2-SQL-TABLECONSTRAINT-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<title> <title>
Description Description
</title> </title>
...@@ -1061,7 +1065,7 @@ disallow this. ...@@ -1061,7 +1065,7 @@ disallow this.
<note> <note>
<para> <para>
<productname>Postgres</productname> does not yet <productname>Postgres</productname> does not yet
(as of version 6.4) support FOREIGN KEY (as of version 6.5) support FOREIGN KEY
integrity constraints. The parser understands the FOREIGN KEY syntax, integrity constraints. The parser understands the FOREIGN KEY syntax,
but only prints a notice and otherwise ignores the clause. but only prints a notice and otherwise ignores the clause.
Foreign keys may be partially emulated by triggers (See the CREATE TRIGGER Foreign keys may be partially emulated by triggers (See the CREATE TRIGGER
...@@ -1070,17 +1074,18 @@ disallow this. ...@@ -1070,17 +1074,18 @@ disallow this.
</note> </note>
</refsect2> </refsect2>
<REFSECT2 ID="R2-SQL-UNIQUECLAUSE-4"> <refsect2 id="R2-SQL-UNIQUECLAUSE-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
UNIQUE Constraint UNIQUE Constraint
</TITLE> </title>
<para> <para>
<synopsis> <synopsis>
[ CONSTRAINT <replaceable class="parameter">name</replaceable> ] UNIQUE ( <replaceable class="parameter">column</replaceable> [, ...] ) [ CONSTRAINT <replaceable class="parameter">name</replaceable> ]
</SYNOPSIS> UNIQUE ( <replaceable class="parameter">column</replaceable> [, ...] )
</synopsis>
</para> </para>
<refsect3> <refsect3>
<title>Inputs</title> <title>Inputs</title>
...@@ -1110,17 +1115,17 @@ disallow this. ...@@ -1110,17 +1115,17 @@ disallow this.
<refsect3> <refsect3>
<title>Outputs</title> <title>Outputs</title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<replaceable>status</replaceable> <replaceable>status</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
ERROR: Cannot insert a duplicate key into a unique index. ERROR: Cannot insert a duplicate key into a unique index.
</term> </term>
<listitem> <listitem>
...@@ -1143,7 +1148,7 @@ disallow this. ...@@ -1143,7 +1148,7 @@ disallow this.
Description Description
</title> </title>
<PARA> <para>
The UNIQUE constraint specifies a rule that a group of one or The UNIQUE constraint specifies a rule that a group of one or
more distinct columns of a table may contain only unique values. more distinct columns of a table may contain only unique values.
The behavior of the UNIQUE table constraint is the same as that for column The behavior of the UNIQUE table constraint is the same as that for column
...@@ -1154,61 +1159,62 @@ disallow this. ...@@ -1154,61 +1159,62 @@ disallow this.
</para> </para>
</refsect3> </refsect3>
<REFSECT3 ID="R3-SQL-UNIQUECLAUSE-4"> <refsect3 id="R3-SQL-UNIQUECLAUSE-4">
<TITLE> <title>
Usage Usage
</title> </title>
<PARA> <para>
Define a UNIQUE table constraint for the table distributors: Define a UNIQUE table constraint for the table distributors:
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(03), did DECIMAL(03),
name VARCHAR(40), name VARCHAR(40),
UNIQUE(name) UNIQUE(name)
); );
</ProgramListing> </programlisting>
</para> </para>
</refsect3> </refsect3>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-PRIMARYKEY-4"> <refsect2 id="R2-SQL-PRIMARYKEY-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
PRIMARY KEY Constraint PRIMARY KEY Constraint
</TITLE> </title>
<para> <para>
<SYNOPSIS> <synopsis>
[ CONSTRAINT <REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE> ] PRIMARY KEY ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) [ CONSTRAINT <replaceable class="PARAMETER">name</replaceable> ]
</SYNOPSIS> PRIMARY KEY ( <replaceable class="PARAMETER">column</replaceable> [, ...] )
</synopsis>
</para> </para>
<refsect3> <refsect3>
<title>Inputs</title> <title>Inputs</title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
CONSTRAINT <ReturnValue><REPLACEABLE CLASS="PARAMETER">name</REPLACEABLE></ReturnValue> CONSTRAINT <returnvalue><replaceable class="PARAMETER">name</replaceable></returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
An arbitrary name for the constraint. An arbitrary name for the constraint.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] <replaceable class="PARAMETER">column</replaceable> [, ...]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The names of one or more columns in the table. The names of one or more columns in the table.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</refsect3> </refsect3>
...@@ -1228,7 +1234,7 @@ disallow this. ...@@ -1228,7 +1234,7 @@ disallow this.
<para> <para>
This occurs at run-time if one tries to insert a duplicate value into This occurs at run-time if one tries to insert a duplicate value into
a column subject to a PRIMARY KEY constraint. a column subject to a PRIMARY KEY constraint.
</PARA> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
...@@ -1240,7 +1246,7 @@ disallow this. ...@@ -1240,7 +1246,7 @@ disallow this.
<refsect3> <refsect3>
<title>Description</title> <title>Description</title>
<PARA> <para>
The PRIMARY KEY constraint specifies a rule that a group of one The PRIMARY KEY constraint specifies a rule that a group of one
or more distinct columns of a table may contain only unique, or more distinct columns of a table may contain only unique,
(non duplicate), non-null values. The column definitions of (non duplicate), non-null values. The column definitions of
...@@ -1249,25 +1255,25 @@ disallow this. ...@@ -1249,25 +1255,25 @@ disallow this.
The PRIMARY KEY table constraint is similar to that for column constraints, The PRIMARY KEY table constraint is similar to that for column constraints,
with the additional capability of encompassing multiple columns. with the additional capability of encompassing multiple columns.
</PARA> </para>
<PARA> <para>
Refer to the section on the PRIMARY KEY column constraint for more Refer to the section on the PRIMARY KEY column constraint for more
information. information.
</para> </para>
</REFSECT3> </refsect3>
</REFSECT2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-CREATETABLE-2"> <refsect1 id="R1-SQL-CREATETABLE-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
Create table films and table distributors Create table films and table distributors
</PARA> </para>
<ProgramListing> <programlisting>
CREATE TABLE films ( CREATE TABLE films (
code CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY, code CHARACTER(5) CONSTRAINT firstkey PRIMARY KEY,
title CHARACTER VARYING(40) NOT NULL, title CHARACTER VARYING(40) NOT NULL,
...@@ -1276,30 +1282,30 @@ disallow this. ...@@ -1276,30 +1282,30 @@ disallow this.
kind CHAR(10), kind CHAR(10),
len INTERVAL HOUR TO MINUTE len INTERVAL HOUR TO MINUTE
); );
</ProgramListing> </programlisting>
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(03) PRIMARY KEY DEFAULT NEXTVAL('serial'), did DECIMAL(03) PRIMARY KEY DEFAULT NEXTVAL('serial'),
name VARCHAR(40) NOT NULL CHECK (name &lt;&gt; '') name VARCHAR(40) NOT NULL CHECK (name &lt;&gt; '')
); );
</ProgramListing> </programlisting>
<PARA> <para>
Create a table with a 2-dimensional array Create a table with a 2-dimensional array
</PARA> </para>
<ProgramListing> <programlisting>
CREATE TABLE array ( CREATE TABLE array (
vector INT[][] vector INT[][]
); );
</ProgramListing> </programlisting>
<PARA> <para>
Define a UNIQUE table constraint for the table films. Define a UNIQUE table constraint for the table films.
UNIQUE table constraints can be defined on one or more UNIQUE table constraints can be defined on one or more
columns of the table columns of the table
</PARA> </para>
<ProgramListing> <programlisting>
CREATE TABLE films ( CREATE TABLE films (
code CHAR(5), code CHAR(5),
title VARCHAR(40), title VARCHAR(40),
...@@ -1309,35 +1315,35 @@ disallow this. ...@@ -1309,35 +1315,35 @@ disallow this.
len INTERVAL HOUR TO MINUTE, len INTERVAL HOUR TO MINUTE,
CONSTRAINT production UNIQUE(date_prod) CONSTRAINT production UNIQUE(date_prod)
); );
</ProgramListing> </programlisting>
<PARA> <para>
Define a CHECK column constraint. Define a CHECK column constraint.
</PARA> </para>
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(3) CHECK (did > 100), did DECIMAL(3) CHECK (did > 100),
name VARCHAR(40) name VARCHAR(40)
); );
</ProgramListing> </programlisting>
<PARA> <para>
Define a CHECK table constraint Define a CHECK table constraint
</PARA> </para>
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(3), did DECIMAL(3),
name VARCHAR(40) name VARCHAR(40)
CONSTRAINT con1 CHECK (did > 100 AND name > '') CONSTRAINT con1 CHECK (did > 100 AND name > '')
); );
</ProgramListing> </programlisting>
<PARA> <para>
Define a PRIMARY KEY table constraint for the table films. Define a PRIMARY KEY table constraint for the table films.
PRIMARY KEY table constraints can be defined on one or more PRIMARY KEY table constraints can be defined on one or more
columns of the table columns of the table
</PARA> </para>
<ProgramListing> <programlisting>
CREATE TABLE films ( CREATE TABLE films (
code CHAR(05), code CHAR(05),
title VARCHAR(40), title VARCHAR(40),
...@@ -1347,14 +1353,14 @@ disallow this. ...@@ -1347,14 +1353,14 @@ disallow this.
len INTERVAL HOUR TO MINUTE, len INTERVAL HOUR TO MINUTE,
CONSTRAINT code_title PRIMARY KEY(code,title) CONSTRAINT code_title PRIMARY KEY(code,title)
); );
</ProgramListing> </programlisting>
<PARA> <para>
Defines a PRIMARY KEY column constraint for table distributors. Defines a PRIMARY KEY column constraint for table distributors.
PRIMARY KEY column constraints can only be defined on one column PRIMARY KEY column constraints can only be defined on one column
of the table (the following two examples are equivalent) of the table (the following two examples are equivalent)
</PARA> </para>
<ProgramListing> <programlisting>
CREATE TABLE distributors ( CREATE TABLE distributors (
did DECIMAL(03), did DECIMAL(03),
name CHAR VARYING(40), name CHAR VARYING(40),
...@@ -1365,39 +1371,39 @@ disallow this. ...@@ -1365,39 +1371,39 @@ disallow this.
did DECIMAL(03) PRIMARY KEY, did DECIMAL(03) PRIMARY KEY,
name VARCHAR(40) name VARCHAR(40)
); );
</ProgramListing> </programlisting>
<REFSECT2 ID="R2-SQL-CREATETABLE-3"> <refsect2 id="R2-SQL-CREATETABLE-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
CREATE TABLE/INHERITS is a <productname>Postgres</productname> CREATE TABLE/INHERITS is a <productname>Postgres</productname>
language extension. language extension.
</PARA> </para>
</refsect2> </refsect2>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-CREATETABLE-3"> <refsect1 id="R1-SQL-CREATETABLE-3">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<REFSECT2 ID="R2-SQL-CREATETABLE-4"> <refsect2 id="R2-SQL-CREATETABLE-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
SQL92 SQL92
</TITLE> </title>
<PARA> <para>
In addition to the normal CREATE TABLE, SQL92 also defines a In addition to the normal CREATE TABLE, SQL92 also defines a
CREATE TEMPORARY TABLE statement: CREATE TEMPORARY TABLE statement:
</PARA> </para>
<synopsis> <synopsis>
CREATE [ {GLOBAL | LOCAL} ] TEMPORARY TABLE table ( CREATE [ {GLOBAL | LOCAL} ] TEMPORARY TABLE table (
column type [DEFAULT value] [CONSTRAINT column_constraint] [, ...] ) column type [DEFAULT value] [CONSTRAINT column_constraint] [, ...] )
...@@ -1431,25 +1437,25 @@ disallow this. ...@@ -1431,25 +1437,25 @@ disallow this.
<tip> <tip>
<para> <para>
In the current release of <productname>Postgres</productname> In the current release of <productname>Postgres</productname>
(v6.4), to create a temporary (v6.5), to create a temporary
table you must create and drop the table by explicit commands. table you must create and drop the table by explicit commands.
</para> </para>
</tip> </tip>
</para> </para>
<REFSECT3 ID="R3-SQL-UNIQUECLAUSE-1"> <refsect3 id="R3-SQL-UNIQUECLAUSE-1">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
UNIQUE clause UNIQUE clause
</TITLE> </title>
<PARA> <para>
SQL92 specifies some additional capabilities for UNIQUE: SQL92 specifies some additional capabilities for UNIQUE:
</para> </para>
<para> <para>
Table Constraint definition Table Constraint definition
</PARA> </para>
<synopsis> <synopsis>
[ CONSTRAINT name ] [ CONSTRAINT name ]
UNIQUE ( column [, ...] ) UNIQUE ( column [, ...] )
...@@ -1467,14 +1473,14 @@ disallow this. ...@@ -1467,14 +1473,14 @@ disallow this.
</synopsis> </synopsis>
</refsect3> </refsect3>
<REFSECT3 ID="R3-SQL-NULL-1"> <refsect3 id="R3-SQL-NULL-1">
<REFSECT3INFO> <refsect3info>
<DATE>1998-12-24</DATE> <date>1998-12-24</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
NULL clause NULL clause
</TITLE> </title>
<PARA> <para>
The NULL "constraint" (actually a non-constraint) The NULL "constraint" (actually a non-constraint)
is a <productname>Postgres</productname> extension to SQL92 is a <productname>Postgres</productname> extension to SQL92
is included for symmetry with the NOT NULL clause. Since it is the default is included for symmetry with the NOT NULL clause. Since it is the default
...@@ -1483,25 +1489,25 @@ disallow this. ...@@ -1483,25 +1489,25 @@ disallow this.
[ CONSTRAINT name ] NULL [ CONSTRAINT name ] NULL
</synopsis> </synopsis>
</para> </para>
</REFSECT3> </refsect3>
<REFSECT3 ID="R3-SQL-NOTNULL-4"> <refsect3 id="R3-SQL-NOTNULL-4">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
NOT NULL clause NOT NULL clause
</TITLE> </title>
<PARA> <para>
SQL92 specifies some additional capabilities for NOT NULL: SQL92 specifies some additional capabilities for NOT NULL:
</PARA> </para>
<synopsis> <synopsis>
[ CONSTRAINT name ] NOT NULL [ CONSTRAINT name ] NOT NULL
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] [ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ] [ [ NOT ] DEFERRABLE ]
</synopsis> </synopsis>
</REFSECT3> </refsect3>
<!-- <!--
I can't figure out why DEFAULT clause is different from what we already have. I can't figure out why DEFAULT clause is different from what we already have.
...@@ -1530,14 +1536,14 @@ the column. Not our problem... ...@@ -1530,14 +1536,14 @@ the column. Not our problem...
</refsect3> </refsect3>
--> -->
<REFSECT3 ID="R3-SQL-CONSTRAINT-3"> <refsect3 id="R3-SQL-CONSTRAINT-3">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
CONSTRAINT clause CONSTRAINT clause
</TITLE> </title>
<PARA> <para>
SQL92 specifies some additional capabilities for constraints, SQL92 specifies some additional capabilities for constraints,
and also defines assertions and domain constraints. and also defines assertions and domain constraints.
<note> <note>
...@@ -1547,7 +1553,7 @@ the column. Not our problem... ...@@ -1547,7 +1553,7 @@ the column. Not our problem...
</para> </para>
</note> </note>
</para> </para>
<PARA> <para>
An assertion is a special type of integrity constraint and share An assertion is a special type of integrity constraint and share
the same namespace as other constraints. the same namespace as other constraints.
However, an assertion is not necessarily dependent on one However, an assertion is not necessarily dependent on one
...@@ -1559,11 +1565,11 @@ the column. Not our problem... ...@@ -1559,11 +1565,11 @@ the column. Not our problem...
CREATE ASSERTION name CHECK ( condition ) CREATE ASSERTION name CHECK ( condition )
</synopsis> </synopsis>
<PARA> <para>
Domain constraints are defined by CREATE DOMAIN or ALTER DOMAIN Domain constraints are defined by CREATE DOMAIN or ALTER DOMAIN
statements: statements:
</para> </para>
<PARA> <para>
Domain constraint: Domain constraint:
</para> </para>
<synopsis> <synopsis>
...@@ -1650,17 +1656,17 @@ the column. Not our problem... ...@@ -1650,17 +1656,17 @@ the column. Not our problem...
</refsect3> </refsect3>
<REFSECT3 ID="R3-SQL-CHECK-4"> <refsect3 id="R3-SQL-CHECK-4">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
CHECK clause CHECK clause
</TITLE> </title>
<PARA> <para>
SQL92 specifies some additional capabilities for CHECK in either SQL92 specifies some additional capabilities for CHECK in either
table or column constraints. table or column constraints.
</PARA> </para>
<!-- <!--
Constraints associated with domains do not need to be mentioned here, Constraints associated with domains do not need to be mentioned here,
even though it is the case that a domain constraint may possibly even though it is the case that a domain constraint may possibly
...@@ -1714,17 +1720,17 @@ affect a column or a table. ...@@ -1714,17 +1720,17 @@ affect a column or a table.
</refsect3> </refsect3>
<REFSECT3 ID="R3-SQL-PRIMARYKEY-1"> <refsect3 id="R3-SQL-PRIMARYKEY-1">
<REFSECT3INFO> <refsect3info>
<DATE>1998-09-11</DATE> <date>1998-09-11</date>
</REFSECT3INFO> </refsect3info>
<TITLE> <title>
PRIMARY KEY clause PRIMARY KEY clause
</TITLE> </title>
<PARA> <para>
SQL92 specifies some additional capabilities for PRIMARY KEY: SQL92 specifies some additional capabilities for PRIMARY KEY:
</para> </para>
<PARA> <para>
Table Constraint definition: Table Constraint definition:
</para> </para>
<synopsis> <synopsis>
...@@ -1747,107 +1753,6 @@ affect a column or a table. ...@@ -1747,107 +1753,6 @@ affect a column or a table.
</refsect1> </refsect1>
</refentry> </refentry>
<REFENTRY ID="SQL-CREATETABLEAS">
<REFMETA>
<REFENTRYTITLE>
CREATE TABLE AS
</REFENTRYTITLE>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO>
</REFMETA>
<REFNAMEDIV>
<REFNAME>
CREATE TABLE AS
</REFNAME>
<REFPURPOSE>
Creates a new table
</REFPURPOSE>
</refnamediv>
<REFSYNOPSISDIV>
<REFSYNOPSISDIVINFO>
<DATE>1998-09-22</DATE>
</REFSYNOPSISDIVINFO>
<SYNOPSIS>
CREATE TABLE <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> [ ( <REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ] AS <REPLACEABLE CLASS="PARAMETER">select_clause</REPLACEABLE>
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-CREATETABLEAS-1">
<REFSECT2INFO>
<DATE>1998-09-22</DATE>
</REFSECT2INFO>
<TITLE>
Inputs
</TITLE>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
The name of a new table to be created.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">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 CLASS="PARAMETER">select_clause</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
A valid query statement. Refer to SELECT for a description of the
allowed syntax.
</PARA>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</para>
</refsect2>
<REFSECT2 ID="R2-SQL-CREATETABLEAS-2">
<REFSECT2INFO>
<DATE>1998-09-22</DATE>
</REFSECT2INFO>
<TITLE>
Outputs
</TITLE>
<PARA>
Refer to CREATE TABLE and SELECT for a summary of possible output
messages.
</para>
</refsect2>
</refsynopsisdiv>
<REFSECT1 ID="R1-SQL-CREATETABLEAS-1">
<REFSECT1INFO>
<DATE>1998-09-22</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<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.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
......
<refentry id="CREATETABLEAS">
<refmeta>
<refentrytitle>
CREATE TABLE AS
</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
CREATE TABLE AS
</refname>
<refpurpose>
Creates a new table
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>1998-09-22</date>
</refsynopsisdivinfo>
<synopsis>
CREATE TABLE <replaceable>table</replaceable> [ (<replaceable>column</replaceable> [, ...] ) ]
AS <replaceable>select_clause</replaceable>
</synopsis>
<refsect2>
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Inputs
</title>
<para>
<variablelist>
<varlistentry>
<term>
<replaceable>table</replaceable>
</term>
<listitem>
<para>
The name of a new table to be created.
</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.
</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.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2>
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Outputs
</title>
<para>
Refer to CREATE TABLE and SELECT for a summary of possible output
messages.
</para>
</refsect2>
</refsynopsisdiv>
<refsect1>
<refsect1info>
<date>1998-09-22</date>
</refsect1info>
<title>
Description
</title>
<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.
</para>
</refsect1>
</refentry>
<!-- 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:
-->
<REFENTRY ID="SQL-CREATEUSER"> <refentry id="SQL-CREATEUSER">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
CREATE USER CREATE USER
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
CREATE USER CREATE USER
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Creates account information for a new user Creates account information for a new user
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-21</DATE> <date>1998-09-21</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
CREATE USER<REPLACEABLE CLASS="PARAMETER"> username</REPLACEABLE> CREATE USER<replaceable class="PARAMETER"> username</replaceable>
[ WITH PASSWORD <REPLACEABLE CLASS="PARAMETER">password</REPLACEABLE> ] [ WITH PASSWORD <replaceable class="PARAMETER">password</replaceable> ]
[ CREATEDB | NOCREATEDB ] [ CREATEDB | NOCREATEDB ]
[ CREATEUSER | NOCREATEUSER ] [ CREATEUSER | NOCREATEUSER ]
[ IN GROUP <REPLACEABLE CLASS="PARAMETER">groupname</REPLACEABLE> [, ...] ] [ IN GROUP <replaceable class="PARAMETER">groupname</replaceable> [, ...] ]
[ VALID UNTIL '<REPLACEABLE CLASS="PARAMETER">abstime</REPLACEABLE>' ] [ VALID UNTIL '<replaceable class="PARAMETER">abstime</replaceable>' ]
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-CREATEUSER-1"> <refsect2 id="R2-SQL-CREATEUSER-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-21</DATE> <date>1998-09-21</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue><replaceable class="parameter">username</replaceable></ReturnValue> <returnvalue><replaceable class="parameter">username</replaceable></returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The name of the user. The name of the user.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY>
<TERM> <varlistentry>
<ReturnValue><replaceable class="parameter">password</replaceable></ReturnValue> <term>
</TERM> <returnvalue><replaceable class="parameter">password</replaceable></returnvalue>
<LISTITEM> </term>
<PARA> <listitem>
The WITH PASSWORD clause sets the user's password within <para>
the "<filename>pg_shadow</filename>" table. For this reason, The WITH PASSWORD clause sets the user's password within
<filename>"pg_shadow</filename>" is no the "<filename>pg_shadow</filename>" table. For this reason,
longer accessible to the instance of <productname>Postgres</productname> that the <filename>"pg_shadow</filename>" is no
<productname>Postgres</productname> user's password is initially set to NULL. longer accessible to the instance of
<comment>The text here has got garbled.</comment> <productname>Postgres</productname> that the
When a <productname>Postgres</productname>
user's password in the "<filename>pg_shadow</filename>" user's password is initially set to NULL.
table is NULL, user </para>
authentication proceeds as it historically has (HBA, <para>
PG_PASSWORD, etc). However, if a password is set for a When a
user, a new authentication system supplants any other user's password in the "<filename>pg_shadow</filename>"
configured for the <productname>Postgres</productname> instance, and the password table is NULL, user
stored in the "<filename>pg_shadow</filename>" table is used authentication proceeds as it historically has (HBA,
for authentication. PG_PASSWORD, etc). However, if a password is set for a
For more details on how this authentication system user, a new authentication system supplants any other
functions see pg_crypt(3). If the WITH PASSWORD clause is configured for the <productname>Postgres</productname>
omitted, the user's password is set to the empty instance, and the password
string with equates to a NULL value in the authentication stored in the "<filename>pg_shadow</filename>" table is used
system mentioned above. for authentication.
</PARA> For more details on how this authentication system
</LISTITEM> functions see pg_crypt(3). If the WITH PASSWORD clause is
</VARLISTENTRY> omitted, the user's password is set to the empty
<VARLISTENTRY> string which equates to a NULL value in the authentication
<TERM> system mentioned above.
<ReturnValue> CREATEDB/NOCREATEDB</ReturnValue> </para>
</TERM> </listitem>
<LISTITEM> </varlistentry>
<PARA>
These clauses define a user's ability to create databases. <varlistentry>
If CREATEDB is specified, the user being defined will <term>
be allowed to create his own databases. Using NOCREATEDB <returnvalue> CREATEDB/NOCREATEDB</returnvalue>
will deny a user the ability to create databases. If this </term>
clause is omitted, NOCREATEDB is used by default. <listitem>
</PARA> <para>
</LISTITEM> These clauses define a user's ability to create databases.
</VARLISTENTRY> If CREATEDB is specified, the user being defined will
<VARLISTENTRY> be allowed to create his own databases. Using NOCREATEDB
<TERM> will deny a user the ability to create databases. If this
<ReturnValue>CREATEUSER/NOCREATEUSER</ReturnValue> clause is omitted, NOCREATEDB is used by default.
</TERM> </para>
<LISTITEM> </listitem>
<PARA> </varlistentry>
These clauses determine whether a user will be permitted to
create new <varlistentry>
users in an instance of <productname>Postgres</productname>. <term>
Omitting this clause will set the user's value of this <returnvalue>CREATEUSER/NOCREATEUSER</returnvalue>
attribute to be NOCREATEUSER. </term>
</PARA> <listitem>
</LISTITEM> <para>
</VARLISTENTRY> These clauses determine whether a user will be permitted to
<VARLISTENTRY> create new
<TERM> users in an instance of <productname>Postgres</productname>.
<ReturnValue><replaceable class="parameter">groupname</replaceable></ReturnValue> Omitting this clause will set the user's value of this
</TERM> attribute to be NOCREATEUSER.
<LISTITEM> </para>
<PARA> </listitem>
A name of a group into which to insert the user as a new member. </varlistentry>
</PARA>
</LISTITEM> <varlistentry>
</VARLISTENTRY> <term>
<VARLISTENTRY> <returnvalue><replaceable class="parameter">groupname</replaceable></returnvalue>
<TERM> </term>
<ReturnValue><replaceable class="parameter">abstime</replaceable></ReturnValue> <listitem>
</TERM> <para>
<LISTITEM> A name of a group into which to insert the user as a new member.
<PARA> </para>
The VALID UNTIL clause sets an absolute time after which the </listitem>
user's <productname>Postgres</productname> login is no longer valid. Please note that </varlistentry>
if a user does not have a password defined in the
"<filename>pg_shadow</filename>" <varlistentry>
table, the valid until date will not be checked <term>
during user authentication. If this clause is omitted, <returnvalue><replaceable class="parameter">abstime</replaceable></returnvalue>
a NULL value is stored in "<filename>pg_shadow</filename>" </term>
for this attribute, <listitem>
and the login will be valid for all time. <para>
</PARA> The VALID UNTIL clause sets an absolute time after which the
</LISTITEM> user's <productname>Postgres</productname>
</VARLISTENTRY> login is no longer valid. Please note that
if a user does not have a password defined in the
"<filename>pg_shadow</filename>"
table, the valid until date will not be checked
during user authentication. If this clause is omitted,
a NULL value is stored in "<filename>pg_shadow</filename>"
for this attribute,
and the login will be valid for all time.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-CREATEUSER-2"> <refsect2 id="R2-SQL-CREATEUSER-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-21</DATE> <date>1998-09-21</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA>
</PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<ReturnValue>CREATE USER</ReturnValue> <returnvalue>CREATE USER</returnvalue>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Message returned if the command completes successfully. Message returned if the command completes successfully.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY>
<TERM> <varlistentry>
<ReturnValue>ERROR: removeUser: user "<replaceable class="parameter">username</replaceable>" does not exist</ReturnValue> <term>
</TERM> <returnvalue>ERROR: removeUser: user "<replaceable
<LISTITEM> class="parameter">username</replaceable>" does not exist</returnvalue>
<PARA> </term>
if "<replaceable class="parameter">username</replaceable>" not found. <listitem>
</PARA> <para>
<comment>I don't understand this and I don't know how to get if "<replaceable class="parameter">username</replaceable>" not found.
this error message.</comment> </para>
</listitem> <comment>I don't understand this and I don't know how to get
</varlistentry> this error message.</comment>
</VARIABLELIST> </listitem>
</REFSECT2> </varlistentry>
</REFSYNOPSISDIV> </variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<REFSECT1 ID="R1-SQL-CREATEUSER-1"> <refsect1 id="R1-SQL-CREATEUSER-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-21</DATE> <date>1998-09-21</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
CREATE USER will add a new user to an instance of CREATE USER will add a new user to an instance of
<productname>Postgres</productname>. <productname>Postgres</productname>.
</PARA> </para>
<PARA> <para>
The new user will be given a <filename>usesysid</filename> of: The new user will be given a <filename>usesysid</filename> of:
'<command>SELECT MAX(usesysid) + 1 FROM pg_shadow</command>'. '<command>SELECT MAX(usesysid) + 1 FROM pg_shadow</command>'.
This means that This means that
...@@ -196,18 +209,18 @@ CREATE USER<REPLACEABLE CLASS="PARAMETER"> username</REPLACEABLE> ...@@ -196,18 +209,18 @@ CREATE USER<REPLACEABLE CLASS="PARAMETER"> username</REPLACEABLE>
for any given user, for any given user,
use the "createuser" script provided with the <productname>Postgres</productname> use the "createuser" script provided with the <productname>Postgres</productname>
distribution. distribution.
</PARA> </para>
<REFSECT2 ID="R2-SQL-CREATEUSER-3"> <refsect2 id="R2-SQL-CREATEUSER-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-21</DATE> <date>1998-09-21</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
CREATE USER statement is a <productname>Postgres</productname> language extension. CREATE USER statement is a <productname>Postgres</productname> language extension.
</PARA> </para>
<para> <para>
Use DROP USER or ALTER USER statements to remove or modify a user Use DROP USER or ALTER USER statements to remove or modify a user
account.</para> account.</para>
...@@ -229,68 +242,67 @@ CREATE USER<REPLACEABLE CLASS="PARAMETER"> username</REPLACEABLE> ...@@ -229,68 +242,67 @@ CREATE USER<REPLACEABLE CLASS="PARAMETER"> username</REPLACEABLE>
| valuntil | abstime | 4 | | valuntil | abstime | 4 |
+--------------------------+--------------------------+-------+ +--------------------------+--------------------------+-------+
</programlisting> </programlisting>
</REFSECT2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-SQL-CREATEUSER-2"> <refsect1 id="R1-SQL-CREATEUSER-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
Create a user with no password: Create a user with no password:
</PARA> </para>
<ProgramListing> <programlisting>
CREATE USER jonathan CREATE USER jonathan
</ProgramListing> </programlisting>
<PARA> <para>
Create a user with a password: Create a user with a password:
</PARA> </para>
<ProgramListing> <programlisting>
CREATE USER davide WITH PASSWORD jw8s0F4 CREATE USER davide WITH PASSWORD jw8s0F4
</ProgramListing> </programlisting>
<para> <para>
Create a user with a password, whose account is valid until the end of 2001. Create a user with a password, whose account is valid until the end of 2001.
Note that after one second has ticked in 2002, the account is not Note that after one second has ticked in 2002, the account is not
valid: valid:
</para> </para>
<ProgramListing> <programlisting>
CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002' CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002'
</ProgramListing> </programlisting>
<para> <para>
Create an account where the user can create databases: Create an account where the user can create databases:
</para> </para>
<ProgramListing> <programlisting>
CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB
</ProgramListing> </programlisting>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-CREATEUSER-3"> <refsect1 id="R1-SQL-CREATEUSER-3">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<PARA> <para>
</PARA> </para>
<REFSECT2 ID="R2-SQL-CREATEUSER-4"> <refsect2 id="R2-SQL-CREATEUSER-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-21</DATE> <date>1998-09-21</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
SQL92 SQL92
</TITLE> </title>
<PARA> <para>
There is no CREATE USER statement in SQL92. There is no CREATE USER statement in SQL92.
</PARA> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>
</REFENTRY> </refentry>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag:t sgml-omittag:nil
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
...@@ -22,7 +22,8 @@ pg_dump [ <replaceable class="parameter">dbname</replaceable> ] ...@@ -22,7 +22,8 @@ pg_dump [ <replaceable class="parameter">dbname</replaceable> ]
pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
[ -t <replaceable class="parameter">table</replaceable> ] [ -t <replaceable class="parameter">table</replaceable> ]
[ -f <replaceable class="parameter">outputfile</replaceable> ] [ -f <replaceable class="parameter">outputfile</replaceable> ]
[ -a ] [ -c ] [ -d ] [ -D ] [ -n ] [ -N ] [ -o ] [ -s ] [ -u ] [ -v ] [ -x ] [ -a ] [ -c ] [ -d ] [ -D ] [ -n ] [ -N ]
[ -o ] [ -s ] [ -u ] [ -v ] [ -x ]
[ <replaceable class="parameter">dbname</replaceable> ] [ <replaceable class="parameter">dbname</replaceable> ]
</SYNOPSIS> </SYNOPSIS>
......
...@@ -206,7 +206,8 @@ postgres [ -B <replaceable class="parameter">nBuffers</replaceable> ] [ -C ] [ - ...@@ -206,7 +206,8 @@ postgres [ -B <replaceable class="parameter">nBuffers</replaceable> ] [ -C ] [ -
"American" format (<literal>MM-DD-YYYY</literal>). "American" format (<literal>MM-DD-YYYY</literal>).
Dates are accepted by the backend in a wide variety of formats, Dates are accepted by the backend in a wide variety of formats,
and for input dates this switch mostly affects the interpretation and for input dates this switch mostly affects the interpretation
for ambiguous cases. See <xref linkend="datatype" endterm="datatype"> for ambiguous cases.
See <xref linkend="datatype-title" endterm="datatype-title">
for more information. for more information.
</para> </para>
</listitem> </listitem>
......
<REFENTRY ID="APP-PSQL"> <refentry id="APP-PSQL">
<REFMETA> <refmeta>
<REFENTRYTITLE id="psql-ref"> <refentrytitle id="psql-ref">
<application>psql</application> <application>psql</application>
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>Application</REFMISCINFO> <refmiscinfo>Application</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
<application>psql</application> <application>psql</application>
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
<productname>Postgres</productname> interactive client <productname>Postgres</productname> interactive client
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-26</DATE> <date>1998-09-26</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
psql [ <replaceable class="parameter">dbname</replaceable> ] psql [ <replaceable class="parameter">dbname</replaceable> ]
psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replaceable class="parameter">dbname</replaceable> ] psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replaceable class="parameter">dbname</replaceable> ]
-e -E [ -f <replaceable class="parameter">filename</replaceable> ] [ -F <replaceable class="parameter">separator</replaceable> ] [ -h <replaceable class="parameter">hostname</replaceable> ] -Hln -e -E [ -f <replaceable class="parameter">filename</replaceable> ]
[ -o <replaceable class="parameter">filename</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ] -qsSt ] [ -T <replaceable class="parameter">table_options</replaceable> ] -ux [ <replaceable class="parameter">dbname</replaceable> ] [ -F <replaceable class="parameter">separator</replaceable> ] [ -h <replaceable class="parameter">hostname</replaceable> ]
</SYNOPSIS> -Hln [ -o <replaceable class="parameter">filename</replaceable> ] [ -p
<replaceable class="parameter">port</replaceable> ]
<REFSECT2 ID="R2-APP-PSQL-1"> -qsSt [ -T <replaceable class="parameter">table_o</replaceable> ] -ux
<REFSECT2INFO> [ <replaceable class="parameter">dbname</replaceable> ]
<DATE>1998-09-26</DATE> </synopsis>
</REFSECT2INFO>
<TITLE> <refsect2 id="R2-APP-PSQL-1">
<refsect2info>
<date>1998-09-26</date>
</refsect2info>
<title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<application>psql</application> accepts many command-line arguments, <application>psql</application> accepts many command-line arguments,
a rich set of meta-commands, and the full <acronym>SQL</acronym> language a rich set of meta-commands, and the full <acronym>SQL</acronym> language
supported by <productname>Postgres</productname>. The most common supported by <productname>Postgres</productname>. The most common
command-line arguments are: command-line arguments are:
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">dbname</REPLACEABLE> <replaceable class="PARAMETER">dbname</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The name of an existing database to access. The name of an existing database to access.
<replaceable class="parameter">dbname</replaceable> <replaceable class="parameter">dbname</replaceable>
defaults to the value of the defaults to the value of the
<envar>USER</envar> <envar>USER</envar>
environment variable or, if that's not set, to the Unix account name of the environment variable or, if that's not set, to the Unix account name of the
current user. current user.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-c <replaceable class="parameter">query</replaceable> -c <replaceable class="parameter">query</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
A single query to run. <application>psql</application> will exit on completion. A single query to run. <application>psql</application> will exit on completion.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
</variablelist> </variablelist>
</para> </para>
...@@ -85,65 +89,65 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea ...@@ -85,65 +89,65 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea
You may set any of the following environment variables to avoid You may set any of the following environment variables to avoid
specifying command-line options: specifying command-line options:
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<envar>PGHOST</envar> <envar>PGHOST</envar>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The <acronym>DNS</acronym> host name of the database server. The <acronym>DNS</acronym> host name of the database server.
Setting <envar>PGHOST</envar> to a non-zero-length string causes Setting <envar>PGHOST</envar> to a non-zero-length string causes
<acronym>TCP/IP</acronym> communication <acronym>TCP/IP</acronym> communication
to be used, rather than the default local Unix domain sockets. to be used, rather than the default local Unix domain sockets.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<envar>PGPORT</envar> <envar>PGPORT</envar>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The port number on which a <productname>Postgres</productname> server is listening. The port number on which a <productname>Postgres</productname> server is listening.
Defaults to <literal>5432</literal>. Defaults to <literal>5432</literal>.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<envar>PGTTY</envar> <envar>PGTTY</envar>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The target for display of messages from the client support library. The target for display of messages from the client support library.
Not required. Not required.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<envar>PGOPTION</envar> <envar>PGOPTION</envar>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
If <envar>PGOPTION</envar> If <envar>PGOPTION</envar>
is specified, then the options it contains are parsed is specified, then the options it contains are parsed
<emphasis>before</emphasis> <emphasis>before</emphasis>
any command-line options. any command-line options.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<envar>PGREALM</envar> <envar>PGREALM</envar>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
<envar>PGREALM</envar> <envar>PGREALM</envar>
only applies if only applies if
<productname>Kerberos</productname> <productname>Kerberos</productname>
...@@ -161,14 +165,14 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea ...@@ -161,14 +165,14 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-APP-PSQL-2"> <refsect2 id="R2-APP-PSQL-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-26</DATE> <date>1998-09-26</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<application>psql</application> <application>psql</application>
returns 0 to the shell on successful completion of all queries, returns 0 to the shell on successful completion of all queries,
1 for errors, 2 for abrupt disconnection from the backend. 1 for errors, 2 for abrupt disconnection from the backend.
...@@ -180,14 +184,14 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea ...@@ -180,14 +184,14 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea
</refsect2> </refsect2>
</refsynopsisdiv> </refsynopsisdiv>
<REFSECT1 ID="R1-APP-PSQL-1"> <refsect1 id="R1-APP-PSQL-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-26</DATE> <date>1998-09-26</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
<application>psql</application> is a character-based front-end to <application>psql</application> is a character-based front-end to
<productname>Postgres</productname>. <productname>Postgres</productname>.
It enables you to It enables you to
...@@ -220,13 +224,13 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea ...@@ -220,13 +224,13 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea
every session. every session.
</para> </para>
<REFSECT2 ID="R2-APP-PSQL-3"> <refsect2 id="R2-APP-PSQL-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-26</DATE> <date>1998-09-26</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Connecting To A Database Connecting To A Database
</TITLE> </title>
<para> <para>
<application>psql</application> <application>psql</application>
attempts to make a connection to the database at the hostname and attempts to make a connection to the database at the hostname and
...@@ -242,13 +246,13 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea ...@@ -242,13 +246,13 @@ psql -A [ -c <replaceable class="parameter">query</replaceable> ] [ -d <replacea
</para> </para>
</refsect2> </refsect2>
<REFSECT2 ID="R2-APP-PSQL-4"> <refsect2 id="R2-APP-PSQL-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-26</DATE> <date>1998-09-26</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Entering Queries Entering Queries
</TITLE> </title>
<para> <para>
In normal operation, In normal operation,
<application>psql</application> provides a prompt with the name of the <application>psql</application> provides a prompt with the name of the
...@@ -288,67 +292,67 @@ testdb=> ...@@ -288,67 +292,67 @@ testdb=>
</refsect2> </refsect2>
<refsect2 id="R2-APP-PSQL-5"> <refsect2 id="R2-APP-PSQL-5">
<Title>Paging To Screen</Title> <title>Paging To Screen</title>
<Note> <note>
<Title>Author</Title> <title>Author</title>
<Para> <para>
From Brett McCormick on the mailing list 1998-04-04. From Brett McCormick on the mailing list 1998-04-04.
</Para> </para>
</Note> </note>
<Para> <para>
To affect the paging behavior of your <Command>psql</Command> output, To affect the paging behavior of your <command>psql</command> output,
set or unset your PAGER environment variable. I always have to set mine set or unset your PAGER environment variable. I always have to set mine
before it will pause. And of course you have to do this before before it will pause. And of course you have to do this before
starting the program. starting the program.
</para> </para>
<Para> <para>
In csh/tcsh or other C shells: In csh/tcsh or other C shells:
<ProgramListing> <programlisting>
% unsetenv PAGER % unsetenv PAGER
</ProgramListing> </programlisting>
while in sh/bash or other Bourne shells: while in sh/bash or other Bourne shells:
<ProgramListing> <programlisting>
% unset PAGER % unset PAGER
</ProgramListing> </programlisting>
</para> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>
<REFSECT1 ID="R1-APP-PSQL-2"> <refsect1 id="R1-APP-PSQL-2">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-26</DATE> <date>1998-09-26</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Command-line Options Command-line Options
</TITLE> </title>
<para> <para>
<application>psql</application> <application>psql</application>
understands the following command-line options: understands the following command-line options:
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-A -A
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Turn off fill justification when printing out table elements. Turn off fill justification when printing out table elements.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-c <replaceable class="parameter">query</replaceable> -c <replaceable class="parameter">query</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Specifies that Specifies that
<application>psql</application> <application>psql</application>
is to execute one query string, is to execute one query string,
...@@ -359,12 +363,12 @@ testdb=> ...@@ -359,12 +363,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-d <replaceable class="parameter">dbname</replaceable> -d <replaceable class="parameter">dbname</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Specifies the name of the database to connect to. This is equivalent to specifying Specifies the name of the database to connect to. This is equivalent to specifying
<replaceable class="parameter">dbname</replaceable> as the last field in the <replaceable class="parameter">dbname</replaceable> as the last field in the
command line. command line.
...@@ -372,34 +376,34 @@ testdb=> ...@@ -372,34 +376,34 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-e -e
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Echo the query sent to the backend Echo the query sent to the backend
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-E -E
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Echo the actual query generated by \d and other backslash commands Echo the actual query generated by \d and other backslash commands
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-f <replaceable class="parameter">filename</replaceable> -f <replaceable class="parameter">filename</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Use the file <replaceable class="parameter">filename</replaceable> Use the file <replaceable class="parameter">filename</replaceable>
as the source of queries instead of reading queries interactively. as the source of queries instead of reading queries interactively.
This file must be specified for and visible to the client frontend. This file must be specified for and visible to the client frontend.
...@@ -407,12 +411,12 @@ testdb=> ...@@ -407,12 +411,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-F <replaceable class="parameter">separator</replaceable> -F <replaceable class="parameter">separator</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Use <replaceable class="parameter">separator</replaceable> Use <replaceable class="parameter">separator</replaceable>
as the field separator. as the field separator.
The default is an ASCII vertical bar ("|"). The default is an ASCII vertical bar ("|").
...@@ -420,12 +424,12 @@ testdb=> ...@@ -420,12 +424,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-h <replaceable class="parameter">hostname</replaceable> -h <replaceable class="parameter">hostname</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Specifies the host name of the machine on which the Specifies the host name of the machine on which the
<application>postmaster</application> <application>postmaster</application>
is running. is running.
...@@ -435,12 +439,12 @@ testdb=> ...@@ -435,12 +439,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-H -H
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Turns on Turns on
<acronym>HTML 3.0</acronym> <acronym>HTML 3.0</acronym>
tabular output. tabular output.
...@@ -448,46 +452,46 @@ testdb=> ...@@ -448,46 +452,46 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-l -l
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Lists all available databases, then exit. Other non-connection options are ignored. Lists all available databases, then exit. Other non-connection options are ignored.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-n -n
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Do not use the readline library for input line editing and command history. Do not use the readline library for input line editing and command history.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-o <replaceable class="parameter">filename</replaceable> -o <replaceable class="parameter">filename</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Put all output into file <replaceable class="parameter">filename</replaceable>. Put all output into file <replaceable class="parameter">filename</replaceable>.
The path must be writable by the client. The path must be writable by the client.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-p <replaceable class="parameter">port</replaceable> -p <replaceable class="parameter">port</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Specifies the TCP/IP port or, by omission, the local Unix domain socket file Specifies the TCP/IP port or, by omission, the local Unix domain socket file
extension on which the extension on which the
<application>postmaster</application> <application>postmaster</application>
...@@ -498,12 +502,12 @@ testdb=> ...@@ -498,12 +502,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-q -q
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Specifies that Specifies that
<application>psql</application> <application>psql</application>
should do its work quietly. By default, it should do its work quietly. By default, it
...@@ -515,36 +519,36 @@ testdb=> ...@@ -515,36 +519,36 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-s -s
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Run in single-step mode where the user is prompted for each query before Run in single-step mode where the user is prompted for each query before
it is sent to the backend. it is sent to the backend.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-S -S
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Runs in single-line mode where each query is terminated by a newline, Runs in single-line mode where each query is terminated by a newline,
instead of a semicolon. instead of a semicolon.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-t -t
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Turn off printing of column names. Turn off printing of column names.
This is useful with the This is useful with the
<option>-c</option> <option>-c</option>
...@@ -553,12 +557,12 @@ testdb=> ...@@ -553,12 +557,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-T <replaceable class="parameter">table_options</replaceable> -T <replaceable class="parameter">table_options</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Allows you to specify options to be placed within the Allows you to specify options to be placed within the
<sgmltag>table ...</sgmltag> tag for <acronym>HTML 3.0</acronym> <sgmltag>table ...</sgmltag> tag for <acronym>HTML 3.0</acronym>
tabular output.For example, <literal>border</literal> tabular output.For example, <literal>border</literal>
...@@ -568,12 +572,12 @@ testdb=> ...@@ -568,12 +572,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-u -u
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Asks the user for the user name and password before connecting to the database. Asks the user for the user name and password before connecting to the database.
If the database does not require password authentication then these are If the database does not require password authentication then these are
ignored. If the option is not used (and the PGPASSWORD environment variable ignored. If the option is not used (and the PGPASSWORD environment variable
...@@ -583,12 +587,12 @@ testdb=> ...@@ -583,12 +587,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
-x -x
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Turns on extended row format mode. When enabled each row will have its column Turns on extended row format mode. When enabled each row will have its column
names printed on the left with the column values printed on the right. names printed on the left with the column values printed on the right.
This is useful for rows which are otherwise too long to fit into This is useful for rows which are otherwise too long to fit into
...@@ -604,13 +608,13 @@ testdb=> ...@@ -604,13 +608,13 @@ testdb=>
</para> </para>
</refsect1> </refsect1>
<REFSECT1 ID="R1-APP-PSQL-3"> <refsect1 id="R1-APP-PSQL-3">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-26</DATE> <date>1998-09-26</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
<application>psql</application> Meta-Commands <application>psql</application> Meta-Commands
</TITLE> </title>
<para> <para>
Anything you enter in <application>psql</application> Anything you enter in <application>psql</application>
that begins with an unquoted backslash is a <application>psql</application> that begins with an unquoted backslash is a <application>psql</application>
...@@ -618,7 +622,7 @@ testdb=> ...@@ -618,7 +622,7 @@ testdb=>
and simply goes into the current query buffer and simply goes into the current query buffer
(and once you have at least one complete query, it gets automatically (and once you have at least one complete query, it gets automatically
submitted to the backend). submitted to the backend).
<Application>psql</Application> meta-commands are also called slash commands. <application>psql</application> meta-commands are also called slash commands.
</para> </para>
<para> <para>
The format of a <application>psql</application> command is the backslash, The format of a <application>psql</application> command is the backslash,
...@@ -634,36 +638,37 @@ testdb=> ...@@ -634,36 +638,37 @@ testdb=>
<para> <para>
The following meta-commands are defined: The following meta-commands are defined:
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\a</literal> <literal>\a</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Toggle field alignment when printing out table elements. Toggle field alignment when printing out table elements.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\C</literal> <replaceable class="parameter">caption</replaceable> <literal>\C</literal> <replaceable class="parameter">caption</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Set the HTML3.0 table caption to Set the HTML3.0 table caption to
<quote><replaceable class="parameter">caption</replaceable></quote>. <quote><replaceable class="parameter">caption</replaceable></quote>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\connect</literal> <replaceable class="parameter">dbname</replaceable> [ <replaceable class="parameter">username</replaceable> ] <literal>\connect</literal> <replaceable class="parameter">meter"</replaceable>ceable> [ <replaceable
</TERM> class="parameter">username</replaceable> ]
<LISTITEM> </term>
<PARA> <listitem>
<para>
Establish a connection to a new database, using the default Establish a connection to a new database, using the default
<replaceable class="parameter">username</replaceable> if none is specified. <replaceable class="parameter">username</replaceable> if none is specified.
The previous connection is closed. The previous connection is closed.
...@@ -671,17 +676,19 @@ testdb=> ...@@ -671,17 +676,19 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\copy</literal> <replaceable class="parameter">dbname</replaceable> { FROM | TO } <replaceable class="parameter">filename</replaceable> <literal>\copy</literal> <replaceable class="parameter">meter"</replaceable>ceable> { FROM | TO }
</TERM> <replaceable class="parameter">filename</replaceable>
<LISTITEM> </term>
<PARA> <listitem>
<para>
Perform a frontend (client) copy. This is an operation that runs a SQL COPY command, Perform a frontend (client) copy. This is an operation that runs a SQL COPY command,
but instead of the backend reading or writing the specified file, and but instead of the backend reading or writing the specified file, and
consequently requiring backend access and special user privilege, consequently requiring backend access and special user privilege,
<application>psql</application> reads or writes the <application>psql</application> reads or writes the
file and routes the data to or from the backend. The default <literal>tab</literal> file and routes the data to or from the backend. The default
<literal>tab</literal>
delimiter is used. delimiter is used.
</para> </para>
<tip> <tip>
...@@ -695,13 +702,14 @@ testdb=> ...@@ -695,13 +702,14 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\d</literal> [ <replaceable class="parameter">table</replaceable> ] <literal>\d</literal> [ <replaceable class="parameter">table</replaceable> ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List tables in the database, or if <replaceable class="parameter">table</replaceable> List tables in the database, or if <replaceable
class="parameter">table</replaceable>
is specified, list the columns in that table. is specified, list the columns in that table.
If table name is specified as an asterisk (<quote>*</quote>), If table name is specified as an asterisk (<quote>*</quote>),
list all tables and column information for each tables. list all tables and column information for each tables.
...@@ -709,23 +717,23 @@ testdb=> ...@@ -709,23 +717,23 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\da</literal> <literal>\da</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List all available aggregates. List all available aggregates.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\dd</literal> <replaceable class="parameter">object</replaceable> <literal>\dd</literal> <replaceable class="parameter">object</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List the description from <literal>pg_description</literal> List the description from <literal>pg_description</literal>
of the specified object, which can be a of the specified object, which can be a
table, table.column, type, operator, or aggregate. table, table.column, type, operator, or aggregate.
...@@ -740,101 +748,101 @@ testdb=> ...@@ -740,101 +748,101 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\df</literal> <literal>\df</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List functions. List functions.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\di</literal> <literal>\di</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List only indexes. List only indexes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\do</literal> <literal>\do</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List only operators. List only operators.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\ds</literal> <literal>\ds</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List only sequences. List only sequences.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\dS</literal> <literal>\dS</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List system tables and indexes. List system tables and indexes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\dt</literal> <literal>\dt</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List only non-system tables. List only non-system tables.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\dT</literal> <literal>\dT</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List types. List types.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\e</literal> [ <replaceable class="parameter">filename</replaceable> ] <literal>\e</literal> [ <replaceable class="parameter">filename</replaceable> ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Edit the current query buffer or the contents of the file Edit the current query buffer or the contents of the file
<replaceable class="parameter">filename</replaceable>. <replaceable class="parameter">filename</replaceable>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\E</literal> [ <replaceable class="parameter">filename</replaceable> ] <literal>\E</literal> [ <replaceable class="parameter">filename</replaceable> ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Edit the current query buffer or the contents of the file Edit the current query buffer or the contents of the file
<replaceable class="parameter">filename</replaceable> <replaceable class="parameter">filename</replaceable>
and execute it upon editor exit. and execute it upon editor exit.
...@@ -842,23 +850,23 @@ testdb=> ...@@ -842,23 +850,23 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\f</literal> [ <replaceable class="parameter">separator</replaceable> ] <literal>\f</literal> [ <replaceable class="parameter">separator</replaceable> ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Set the field separator. Default is a single blank space. Set the field separator. Default is a single blank space.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\g</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ] <literal>\g</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Send the current query input buffer to the backend and optionally Send the current query input buffer to the backend and optionally
save the output in <replaceable class="parameter">filename</replaceable> save the output in <replaceable class="parameter">filename</replaceable>
or pipe the output into a separate Unix shell to execute or pipe the output into a separate Unix shell to execute
...@@ -867,12 +875,12 @@ testdb=> ...@@ -867,12 +875,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\h</literal> [ <replaceable class="parameter">command</replaceable> ] <literal>\h</literal> [ <replaceable class="parameter">command</replaceable> ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Give syntax help on the specified SQL command. Give syntax help on the specified SQL command.
If <replaceable class="parameter">command</replaceable> is not a defined SQL command If <replaceable class="parameter">command</replaceable> is not a defined SQL command
(or is not documented in <application>psql</application>), or if (or is not documented in <application>psql</application>), or if
...@@ -886,47 +894,48 @@ testdb=> ...@@ -886,47 +894,48 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\H</literal> <literal>\H</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Toggle <acronym>HTML3</acronym> output. This is equivalent to the <option>-H</option> Toggle <acronym>HTML3</acronym> output. This is equivalent to
the <option>-H</option>
command-line option. command-line option.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\i</literal> <replaceable class="parameter">filename</replaceable> <literal>\i</literal> <replaceable class="parameter">filename</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Read queries from the file <replaceable class="parameter">filename</replaceable> Read queries from the file <replaceable class="parameter">filename</replaceable>
into the query input buffer. into the query input buffer.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\l</literal> <literal>\l</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
List all the databases in the server. List all the databases in the server.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\m</literal> <literal>\m</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Toggle the old monitor-like table display, which includes border characters Toggle the old monitor-like table display, which includes border characters
surrounding the table. surrounding the table.
This is standard SQL output. This is standard SQL output.
...@@ -936,12 +945,12 @@ testdb=> ...@@ -936,12 +945,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\o</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ] <literal>\o</literal> [ { <replaceable class="parameter">filename</replaceable> | <literal>|</literal><replaceable class="parameter">command</replaceable> } ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Save future query results to the file Save future query results to the file
<replaceable class="parameter">filename</replaceable> or pipe future <replaceable class="parameter">filename</replaceable> or pipe future
results into a separate Unix shell to execute results into a separate Unix shell to execute
...@@ -952,45 +961,45 @@ testdb=> ...@@ -952,45 +961,45 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\p</literal> <literal>\p</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Print the current query buffer. Print the current query buffer.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\q</literal> <literal>\q</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Quit the <application>psql</application> program. Quit the <application>psql</application> program.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\r</literal> <literal>\r</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Reset(clear) the query buffer. Reset(clear) the query buffer.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\s</literal> [ <replaceable class="parameter">filename</replaceable> ] <literal>\s</literal> [ <replaceable class="parameter">filename</replaceable> ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Print or save the command line history to Print or save the command line history to
<replaceable class="parameter">filename</replaceable>. <replaceable class="parameter">filename</replaceable>.
If <replaceable class="parameter">filename</replaceable> is omitted, If <replaceable class="parameter">filename</replaceable> is omitted,
...@@ -1001,23 +1010,23 @@ testdb=> ...@@ -1001,23 +1010,23 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\t</literal> <literal>\t</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Toggle display of output column name headings and row count footer (defaults to on). Toggle display of output column name headings and row count footer (defaults to on).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\T</literal> <replaceable class="parameter">table_options</replaceable> <literal>\T</literal> <replaceable class="parameter">table_options</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Allows you to specify options to be placed within the Allows you to specify options to be placed within the
<sgmltag>table ...</sgmltag> tag <sgmltag>table ...</sgmltag> tag
for <acronym>HTML 3.0</acronym> for <acronym>HTML 3.0</acronym>
...@@ -1028,12 +1037,12 @@ testdb=> ...@@ -1028,12 +1037,12 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\x</literal> <literal>\x</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Toggles extended row format mode. When enabled each row will have its column Toggles extended row format mode. When enabled each row will have its column
names printed on the left with the column values printed on the right. names printed on the left with the column values printed on the right.
This is useful for rows which are otherwise too long to fit into This is useful for rows which are otherwise too long to fit into
...@@ -1042,48 +1051,48 @@ testdb=> ...@@ -1042,48 +1051,48 @@ testdb=>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\w</literal> <replaceable class="parameter">filename</replaceable> <literal>\w</literal> <replaceable class="parameter">filename</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Outputs the current query buffer to the file Outputs the current query buffer to the file
<replaceable class="parameter">filename</replaceable>. <replaceable class="parameter">filename</replaceable>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\z</literal> <literal>\z</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Produces a list of all tables in the database with their appropriate ACLs Produces a list of all tables in the database with their appropriate ACLs
(grant/revoke permissions) listed. (grant/revoke permissions) listed.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\!</literal> [ <replaceable class="parameter">command</replaceable> ] <literal>\!</literal> [ <replaceable class="parameter">command</replaceable> ]
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Escape to a separate Unix shell or execute the Unix command Escape to a separate Unix shell or execute the Unix command
<replaceable class="parameter">command</replaceable>. <replaceable class="parameter">command</replaceable>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<literal>\?</literal> <literal>\?</literal>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Get help information about the slash (<quote>\</quote>) commands. Get help information about the slash (<quote>\</quote>) commands.
</para> </para>
</listitem> </listitem>
......
<REFENTRY ID="SQL-RESET"> <refentry id="SQL-RESET">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
RESET RESET
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
RESET RESET
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Restores run-time parameters for session to default values Restores run-time parameters for session to default values
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
RESET <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> RESET <replaceable class="PARAMETER">variable</replaceable>
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-RESET-1"> <refsect2 id="R2-SQL-RESET-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> <replaceable class="PARAMETER">variable</replaceable>
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Refer to the SET statement for more information on available Refer to the SET statement for more information on available
variables. variables.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-RESET-2"> <refsect2 id="R2-SQL-RESET-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
RESET VARIABLE RESET VARIABLE
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Message returned if Message returned if
<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> is successfully reset <replaceable class="PARAMETER">variable</replaceable> is successfully reset
to its default value.. to its default value..
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-RESET-1"> <refsect1 id="R1-SQL-RESET-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA> <para>
<command>RESET</command> restores variables to the <command>RESET</command> restores variables to the
default values. default values.
Refer to the <command>SET</command> command for details on Refer to the <command>SET</command> command for details on
allowed values and defaults. allowed values and defaults.
<command>RESET</command> is an alternate form for <command>RESET</command> is an alternate form for
<synopsis> <command>SET <replaceable class="parameter">variable</replaceable> = DEFAULT</command>
<command>SET <replaceable class="parameter">variable</replaceable> = DEFAULT</command> </para>
</synopsis>
</para>
<REFSECT2 ID="R2-SQL-RESET-3"> <refsect2 id="R2-SQL-RESET-3">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Notes Notes
</TITLE> </title>
<PARA> <para>
The RESET statement is a <productname>Postgres</productname> language extension. The RESET statement is a <productname>Postgres</productname>
</para> language extension.
<para> </para>
Refer to SET/SHOW statements to set/show variable values. <para>
</para> Refer to SET/SHOW statements to set/show variable values.
</REFSECT2> </para>
</refsect1> </refsect2>
</refsect1>
<REFSECT1 ID="R1-SQL-RESET-2"> <refsect1 id="R1-SQL-RESET-2">
<TITLE> <title>
Usage Usage
</TITLE> </title>
<PARA> <para>
<ProgramListing> <programlisting>
-- reset DateStyle to its default; -- reset DateStyle to its default;
RESET DateStyle; RESET DateStyle;
</programlisting> </programlisting>
<programlisting> <programlisting>
-- reset Geqo to its default; -- reset Geqo to its default;
RESET GEQO; RESET GEQO;
</ProgramListing> </programlisting>
</para> </para>
</REFSECT1> </refsect1>
<refsect1 id="R1-SQL-RESET-3">
<title>
Compatibility
</title>
<REFSECT1 ID="R1-SQL-RESET-3"> <refsect2 id="R2-SQL-RESET-4">
<TITLE> <refsect2info>
Compatibility <date>1998-09-24</date>
</TITLE> </refsect2info>
<title>
SQL92
</title>
<para>
There is no <command>RESET</command> in <acronym>SQL92</acronym>.
</para>
</refsect2>
</refsect1>
</refentry>
<REFSECT2 ID="R2-SQL-RESET-4"> <!-- Keep this comment at the end of the file
<REFSECT2INFO> Local variables:
<DATE>1998-09-24</DATE> mode: sgml
</REFSECT2INFO> sgml-omittag:nil
<TITLE> sgml-shorttag:t
SQL92 sgml-minimize-attributes:nil
</TITLE> sgml-always-quote-attributes:t
<PARA> sgml-indent-step:1
There is no <command>RESET</command> in <acronym>SQL92</acronym>. sgml-indent-data:t
</para> sgml-parent-document:nil
</refsect2> sgml-default-dtd-file:"../reference.ced"
</refsect1> sgml-exposed-tags:nil
</REFENTRY> sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil
End:
-->
<REFENTRY ID="SQL-REVOKE"> <refentry id="SQL-REVOKE">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
REVOKE REVOKE
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
REVOKE REVOKE
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Revokes access privilege from a user, a group or all users. Revokes access privilege from a user, a group or all users.
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
<REPLACEABLE CLASS="PARAMETER"> REVOKE <replaceable class="PARAMETER">privilege</replaceable> [, ...]
</REPLACEABLE> ON <replaceable class="PARAMETER">object</replaceable> [, ...]
REVOKE <REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE> [, ...] FROM { PUBLIC | GROUP <replaceable class="PARAMETER">ER">g</replaceable>BLE> | <replaceable class="PARAMETER">username</replaceable> }
ON <REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE> [, ...] </synopsis>
FROM { PUBLIC | GROUP <REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE> | <REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE> }
</SYNOPSIS>
<REFSECT2 ID="R2-SQL-REVOKE-1"> <refsect2 id="R2-SQL-REVOKE-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">privilege</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
The possible privileges are:
</para>
</listitem>
</varlistentry>
<VARLISTENTRY> <variablelist>
<TERM> <varlistentry>
SELECT <term>
</TERM> <replaceable class="PARAMETER">privilege</replaceable>
<LISTITEM> </term>
<PARA> <listitem>
Privilege to access all of the columns of a specific <para>
table/view. The possible privileges are:
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY>
<TERM>
INSERT
</TERM>
<LISTITEM>
<PARA>
Privilege to insert data into all columns of a
specific table.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
UPDATE
</TERM>
<LISTITEM>
<PARA>
Privilege to update all columns of a specific
table.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
DELETE
</TERM>
<LISTITEM>
<PARA>
Privilege to delete rows from a specific table.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
RULE
</TERM>
<LISTITEM>
<PARA>
Privilege to define rules on table/view.
(See <command>CREATE RULE</command>).
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
ALL
</TERM>
<LISTITEM>
<PARA>
Rescind all privileges.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">object</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
The name of an object from which to revoke access.
The possible objects are:
<itemizedlist mark="bullet" spacing="compact">
<listitem>
<para>
table
</para>
</listitem>
<listitem>
<para>
view
</para>
</listitem>
<listitem>
<para>
sequence
</para>
</listitem>
<listitem>
<para>
index
</para>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">group</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
The name of a group from whom to revoke privileges.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">username</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
The name of a user from whom revoke privileges. Use the PUBLIC keyword
to specify all users.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
PUBLIC
</TERM>
<LISTITEM>
<PARA>
Rescind the specified privilege(s) for all users.
</para>
</LISTITEM>
</VARLISTENTRY>
</VARIABLELIST>
</para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-REVOKE-2"> <varlistentry>
<REFSECT2INFO> <term>
<DATE>1998-09-24</DATE> SELECT
</REFSECT2INFO> </term>
<TITLE> <listitem>
Outputs <para>
</TITLE> Privilege to access all of the columns of a specific
<PARA> table/view.
</para>
<VARIABLELIST> </listitem>
<VARLISTENTRY> </varlistentry>
<TERM>
CHANGE
</TERM>
<LISTITEM>
<PARA>
Message returned if successfully.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
ERROR
</TERM>
<LISTITEM>
<PARA>
Message returned if object is not available or impossible
to revoke privileges from a group or users.
</para>
</listitem>
</varlistentry>
</VARIABLELIST>
</para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFSECT1 ID="R1-SQL-REVOKE-1">
<REFSECT1INFO>
<DATE>1998-09-24</DATE>
</REFSECT1INFO>
<TITLE>
Description
</TITLE>
<PARA>
REVOKE allows creator of an object to revoke permissions granted
before, from all users (via PUBLIC) or a certain user or group.
</para>
<REFSECT2 ID="R2-SQL-REVOKE-3"> <varlistentry>
<REFSECT2INFO> <term>
<DATE>1998-09-24</DATE> INSERT
</REFSECT2INFO> </term>
<TITLE> <listitem>
Notes <para>
</TITLE> Privilege to insert data into all columns of a
<PARA> specific table.
Refer to psql \z command for further information about permissions </para>
on existing objects: </listitem>
</varlistentry>
<programlisting>
Database = lusitania
+------------------+---------------------------------------------+
| Relation | Grant/Revoke Permissions |
+------------------+---------------------------------------------+
| mytable | {"=rw","miriam=arwR","group todos=rw"} |
+------------------+---------------------------------------------+
Legend:
uname=arwR -- privileges granted to a user
group gname=arwR -- privileges granted to a GROUP
=arwR -- privileges granted to PUBLIC
r -- SELECT
w -- UPDATE/DELETE
a -- INSERT
R -- RULE
arwR -- ALL
</programlisting>
</para>
<tip>
<para>
Currently, to create a GROUP you have to insert
data manually into table pg_group as:
<programlisting>
INSERT INTO pg_group VALUES ('todos');
CREATE USER miriam IN GROUP todos;
</programlisting>
</para>
</tip>
</REFSECT2> <varlistentry>
</refsect1> <term>
UPDATE
</term>
<listitem>
<para>
Privilege to update all columns of a specific
table.
</para>
</listitem>
</varlistentry>
<REFSECT1 ID="R1-SQL-REVOKE-2"> <varlistentry>
<TITLE> <term>
Usage DELETE
</TITLE> </term>
<PARA> <listitem>
<ProgramListing> <para>
-- revoke insert privilege from all users on table films: Privilege to delete rows from a specific table.
-- </para>
REVOKE INSERT ON films FROM PUBLIC; </listitem>
</varlistentry>
-- revoke all privileges from user manuel on view kinds:
--
REVOKE ALL ON kinds FROM manuel;
</ProgramListing>
</para>
</REFSECT1>
<REFSECT1 ID="R1-SQL-REVOKE-3">
<TITLE>
Compatibility
</TITLE>
<REFSECT2 ID="R2-SQL-REVOKE-4">
<REFSECT2INFO>
<DATE>1998-09-01</DATE>
</REFSECT2INFO>
<TITLE>
SQL92
</TITLE>
<PARA>
The SQL92 syntax for <command>REVOKE</command>
has additional capabilities for rescinding
privileges, including those on individual columns in tables:
<variablelist> <varlistentry>
<varlistentry> <term>
<term> RULE
<synopsis> </term>
REVOKE { SELECT | DELETE | USAGE | ALL PRIVILEGES } [, ...] <listitem>
ON <replaceable class="parameter">object</replaceable> <para>
FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE } Privilege to define rules on table/view.
REVOKE { INSERT | UPDATE | REFERENCES } [, ...] [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ] (See <command>CREATE RULE</command>).
ON <replaceable class="parameter">object</replaceable> </para>
FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE } </listitem>
</synopsis> </varlistentry>
</term>
<listitem> <varlistentry>
<para> <term>
Refer to the <command>GRANT</command> command for details on individual fields. ALL
</para> </term>
</listitem> <listitem>
</varlistentry> <para>
Rescind all privileges.
<varlistentry> </para>
<term> </listitem>
<synopsis> </varlistentry>
REVOKE GRANT OPTION FOR <replaceable class="parameter">privilege</replaceable> [, ...]
ON <replaceable class="parameter">object</replaceable> <varlistentry>
FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE } <term>
</synopsis> <replaceable class="PARAMETER">object</replaceable>
</term> </term>
<listitem> <listitem>
<para> <para>
Rescinds authority for a user to grant the specified privilege to others. The name of an object from which to revoke access.
Refer to the <command>GRANT</command> command for details on individual fields. The possible objects are:
</para> <itemizedlist spacing="compact" mark="bullet">
</listitem> <listitem>
</varlistentry> <para>
</variablelist> table
</para> </para>
</listitem>
<listitem>
<para> <para>
The possible objects are: view
<simplelist>
<member> [ TABLE ] table/view
</member>
<member> CHARACTER SET character-set
</member>
<member> COLLATION collation
</member>
<member> TRANSLATION translation
</member>
<member> DOMAIN domain
</member>
</simplelist>
</para> </para>
<para> </listitem>
If user1 gives a privilege WITH GRANT OPTION to user2,
and user2 gives it to user3 then user1 can revoke <listitem>
this privilege in cascade using the CASCADE keyword. <para>
sequence
</para> </para>
</listitem>
<listitem>
<para> <para>
If user1 gives a privilege WITH GRANT OPTION to user2, index
and user2 gives it to user3 then if user1 try revoke
this privilege it fails if he/she specify the RESTRICT
keyword.
</para> </para>
</refsect2> </listitem>
</refsect1> </itemizedlist>
</REFENTRY> </para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<replaceable class="PARAMETER">group</replaceable>
</term>
<listitem>
<para>
The name of a group from whom to revoke privileges.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<replaceable class="PARAMETER">username</replaceable>
</term>
<listitem>
<para>
The name of a user from whom revoke privileges. Use the PUBLIC keyword
to specify all users.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
PUBLIC
</term>
<listitem>
<para>
Rescind the specified privilege(s) for all users.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2 id="R2-SQL-REVOKE-2">
<refsect2info>
<date>1998-09-24</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<variablelist>
<varlistentry>
<term>
CHANGE
</term>
<listitem>
<para>
Message returned if successfully.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
ERROR
</term>
<listitem>
<para>
Message returned if object is not available or impossible
to revoke privileges from a group or users.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-SQL-REVOKE-1">
<refsect1info>
<date>1998-09-24</date>
</refsect1info>
<title>
Description
</title>
<para>
REVOKE allows creator of an object to revoke permissions granted
before, from all users (via PUBLIC) or a certain user or group.
</para>
<refsect2 id="R2-SQL-REVOKE-3">
<refsect2info>
<date>1998-09-24</date>
</refsect2info>
<title>
Notes
</title>
<para>
Refer to psql \z command for further information about permissions
on existing objects:
<programlisting>
Database = lusitania
+------------------+---------------------------------------------+
| Relation | Grant/Revoke Permissions |
+------------------+---------------------------------------------+
| mytable | {"=rw","miriam=arwR","group todos=rw"} |
+------------------+---------------------------------------------+
Legend:
uname=arwR -- privileges granted to a user
group gname=arwR -- privileges granted to a GROUP
=arwR -- privileges granted to PUBLIC
r -- SELECT
w -- UPDATE/DELETE
a -- INSERT
R -- RULE
arwR -- ALL
</programlisting>
</para>
<tip>
<para>
Currently, to create a GROUP you have to insert
data manually into table pg_group as:
<programlisting>
INSERT INTO pg_group VALUES ('todos');
CREATE USER miriam IN GROUP todos;
</programlisting>
</para>
</tip>
</refsect2>
</refsect1>
<refsect1 id="R1-SQL-REVOKE-2">
<title>
Usage
</title>
<para>
<programlisting>
-- revoke insert privilege from all users on table films:
--
REVOKE INSERT ON films FROM PUBLIC;
</programlisting>
<programlisting>
-- revoke all privileges from user manuel on view kinds:
--
REVOKE ALL ON kinds FROM manuel;
</programlisting>
</para>
</refsect1>
<refsect1 id="R1-SQL-REVOKE-3">
<title>
Compatibility
</title>
<refsect2 id="R2-SQL-REVOKE-4">
<refsect2info>
<date>1998-09-01</date>
</refsect2info>
<title>
SQL92
</title>
<para>
The SQL92 syntax for <command>REVOKE</command>
has additional capabilities for rescinding
privileges, including those on individual columns in tables:
<variablelist>
<varlistentry>
<term>
<synopsis>
REVOKE { SELECT | DELETE | USAGE | ALL PRIVILEGES } [, ...]
ON <replaceable class="parameter">object</replaceable>
FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
REVOKE { INSERT | UPDATE | REFERENCES } [, ...] [ ( <replaceable class="parameter">column</replaceable> [, ...] ) ]
ON <replaceable class="parameter">object</replaceable>
FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
</synopsis>
</term>
<listitem>
<para>
Refer to <command>GRANT</command> for details on individual fields.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<synopsis>
REVOKE GRANT OPTION FOR <replaceable class="parameter">privilege</replaceable> [, ...]
ON <replaceable class="parameter">object</replaceable>
FROM { PUBLIC | <replaceable class="parameter">username</replaceable> [, ...] } { RESTRICT | CASCADE }
</synopsis>
</term>
<listitem>
<para>
Rescinds authority for a user to grant the specified privilege
to others.
Refer to the <command>GRANT</command> command for details
on individual fields.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
The possible objects are:
<simplelist>
<member>
[ TABLE ] table/view
</member>
<member>
CHARACTER SET character-set
</member>
<member>
COLLATION collation
</member>
<member>
TRANSLATION translation
</member>
<member>
DOMAIN domain
</member>
</simplelist>
</para>
<para>
If user1 gives a privilege WITH GRANT OPTION to user2,
and user2 gives it to user3 then user1 can revoke
this privilege in cascade using the CASCADE keyword.
</para>
<para>
If user1 gives a privilege WITH GRANT OPTION to user2,
and user2 gives it to user3 then if user1 try revoke
this privilege it fails if he/she specify the RESTRICT
keyword.
</para>
</refsect2>
</refsect1>
</refentry>
<!-- 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:
-->
<REFENTRY ID="SQL-ROLLBACK"> <refentry id="SQL-ROLLBACK">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle id="SQL-ROLLBACK-TITLE">
ROLLBACK ROLLBACK
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
ROLLBACK ROLLBACK
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Aborts the current transaction Aborts the current transaction
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
ROLLBACK [ WORK ] ROLLBACK [ WORK | TRANSACTION ]
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-ROLLBACK-1"> <refsect2 id="R2-SQL-ROLLBACK-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
None. None.
</para> </para>
</REFSECT2> </refsect2>
<REFSECT2 ID="R2-SQL-ROLLBACK-2"> <refsect2 id="R2-SQL-ROLLBACK-2">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Outputs Outputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
ABORT ABORT
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
Message returned if successful. Message returned if successful.
</para> </para>
</listitem> </listitem>
</VARLISTENTRY> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
NOTICE: UserAbortTransactionBlock and not in in-progress state NOTICE: UserAbortTransactionBlock and not in in-progress state
ABORT ABORT
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
If there is not any transaction currently in progress. If there is not any transaction currently in progress.
</para> </para>
</listitem> </listitem>
</VARLISTENTRY> </varlistentry>
</VARIABLELIST> </variablelist>
</para> </para>
</REFSECT2> </refsect2>
</REFSYNOPSISDIV> </refsynopsisdiv>
<REFSECT1 ID="R1-SQL-ROLLBACK-1"> <refsect1 id="R1-SQL-ROLLBACK-1">
<REFSECT1INFO> <refsect1info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT1INFO> </refsect1info>
<TITLE> <title>
Description Description
</TITLE> </title>
<PARA>
<command>ROLLBACK</command> rolls back the current transaction and causes
all the updates made by the transaction to be discarded.
</para>
<REFSECT2 ID="R2-SQL-ROLLBACK-3">
<REFSECT2INFO>
<DATE>1998-09-24</DATE>
</REFSECT2INFO>
<TITLE>
Notes
</TITLE>
<PARA>
The keyword WORK is noise and can be omitted.
</para>
<para>
Use the <command>COMMIT</command> statement to successfully
terminate a transaction.
</para>
</refsect2>
</REFSECT1>
<REFSECT1 ID="R1-SQL-ROLLBACK-2"> <para>
<TITLE> <command>ROLLBACK</command> rolls back the current transaction and causes
Usage all the updates made by the transaction to be discarded.
</TITLE> </para>
<PARA>
<ProgramListing> <refsect2 id="R2-SQL-ROLLBACK-3">
--To abort all changes: <refsect2info>
-- <date>1998-09-24</date>
ROLLBACK WORK; </refsect2info>
</ProgramListing> <title>
</para> Notes
</REFSECT1> </title>
<para>
<REFSECT1 ID="R1-SQL-ROLLBACK-3"> The keywords WORK and TRANSACTION are noise and can be omitted.
<TITLE> </para>
Compatibility
</TITLE> <para>
<PARA> Use <xref linkend="SQL-COMMIT-TITLE" endterm="SQL-COMMIT-TITLE">
</PARA> to successfully terminate a transaction.
</para>
<REFSECT2 ID="R2-SQL-ROLLBACK-4"> </refsect2>
<REFSECT2INFO> </refsect1>
<DATE>1998-09-24</DATE>
</REFSECT2INFO> <refsect1 id="R1-SQL-ROLLBACK-2">
<TITLE> <title>
SQL92 Usage
</TITLE> </title>
<PARA> <para>
Full compatibility. <programlisting>
</para> --To abort all changes:
</refsect2> --
</refsect1> ROLLBACK WORK;
</REFENTRY> </programlisting>
</para>
</refsect1>
<refsect1 id="R1-SQL-ROLLBACK-3">
<title>
Compatibility
</title>
<para>
</para>
<refsect2 id="R2-SQL-ROLLBACK-4">
<refsect2info>
<date>1998-09-24</date>
</refsect2info>
<title>
SQL92
</title>
<para>
Full compatibility. TRANSACTION is a
<productname>Postgres</productname> extension.
</para>
</refsect2>
</refsect1>
</refentry>
<!-- 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:
-->
...@@ -18,13 +18,16 @@ SELECT ...@@ -18,13 +18,16 @@ SELECT
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
<replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...] <replaceable class="PARAMETER">expression</replaceable> [ AS
<replaceable class="PARAMETER">name</replaceable> ] [, ...]
[ INTO [TEMP] [TABLE] <replaceable class="PARAMETER">new_table</replaceable> ] [ INTO [TEMP] [TABLE] <replaceable class="PARAMETER">new_table</replaceable> ]
[ FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable> ] [, ...] ] [ FROM <replaceable class="PARAMETER">table</replaceable>
[<replaceable class="PARAMETER">alias</replaceable> ] [, ...] ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ] [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ] [ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ] [ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
[ { UNION [ALL] | INTERSECT | EXCEPT } <replaceable class="PARAMETER">select</replaceable> ] [ { UNION [ALL] | INTERSECT | EXCEPT } <replaceable
class="PARAMETER">select</replaceable> ]
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
[ FOR UPDATE [OF class_name...]] [ FOR UPDATE [OF class_name...]]
[ LIMIT count [OFFSET|, count]] [ LIMIT count [OFFSET|, count]]
...@@ -66,17 +69,17 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -66,17 +69,17 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</listitem> </listitem>
</varlistentry> </varlistentry>
<VARLISTENTRY> <varlistentry>
<TERM> <term>
TEMP TEMP
</TERM> </term>
<LISTITEM> <listitem>
<PARA> <para>
The table is created unique to this session, and is The table is created unique to this session, and is
automatically dropped on session exit. automatically dropped on session exit.
</PARA> </para>
</LISTITEM> </listitem>
</VARLISTENTRY> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>
...@@ -215,7 +218,8 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -215,7 +218,8 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
<command>DISTINCT</command> will eliminate all duplicate rows from the <command>DISTINCT</command> will eliminate all duplicate rows from the
selection. selection.
<command>DISTINCT ON <replaceable class="PARAMETER">column</replaceable></command> will eliminate all duplicates in the specified column; this is <command>DISTINCT ON <replaceable class="PARAMETER">column</replaceable></command> will eliminate all duplicates in the specified column; this is
equivalent to using <command>GROUP BY <replaceable class="PARAMETER">column</replaceable></command>. <command>ALL</command> will return all candidate rows, equivalent to using <command>GROUP BY <replaceable
class="PARAMETER">column</replaceable></command>. <command>ALL</command> will return all candidate rows,
including duplicates.</para> including duplicates.</para>
<para> <para>
...@@ -269,7 +273,9 @@ including duplicates.</para> ...@@ -269,7 +273,9 @@ including duplicates.</para>
The optional WHERE condition has the general form: The optional WHERE condition has the general form:
<synopsis> <synopsis>
WHERE <replaceable class="PARAMETER">expr</replaceable> <replaceable class="PARAMETER">cond_op</replaceable> <replaceable class="PARAMETER">expr</replaceable> [ <replaceable class="PARAMETER">log_op</replaceable> ... ] WHERE <replaceable class="PARAMETER">expr</replaceable> <replaceable
class="PARAMETER">ETER">c</replaceable>e<replaceable class="PARAMETER">"PAR</replaceable>replaceable> [ <replaceable
class="PARAMETER">log_op</replaceable> ... ]
</synopsis> </synopsis>
where <replaceable class="PARAMETER">cond_op</replaceable> can be where <replaceable class="PARAMETER">cond_op</replaceable> can be
...@@ -381,7 +387,8 @@ SELECT name FROM distributors ORDER BY code; ...@@ -381,7 +387,8 @@ SELECT name FROM distributors ORDER BY code;
</title> </title>
<para> <para>
<synopsis> <synopsis>
<replaceable class="PARAMETER">table_query</replaceable> UNION [ ALL ] <replaceable class="PARAMETER">table_query</replaceable> <replaceable class="PARAMETER">table_query</replaceable> UNION [ ALL ]
<replaceable class="PARAMETER">table_query</replaceable>
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
</synopsis> </synopsis>
...@@ -417,7 +424,8 @@ SELECT name FROM distributors ORDER BY code; ...@@ -417,7 +424,8 @@ SELECT name FROM distributors ORDER BY code;
</title> </title>
<para> <para>
<synopsis> <synopsis>
<replaceable class="PARAMETER">table_query</replaceable> INTERSECT <replaceable class="PARAMETER">table_query</replaceable> <replaceable class="PARAMETER">table_query</replaceable> INTERSECT
<replaceable class="PARAMETER">table_query</replaceable>
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
</synopsis> </synopsis>
...@@ -448,7 +456,8 @@ SELECT name FROM distributors ORDER BY code; ...@@ -448,7 +456,8 @@ SELECT name FROM distributors ORDER BY code;
</title> </title>
<para> <para>
<synopsis> <synopsis>
<replaceable class="PARAMETER">table_query</replaceable> EXCEPT <replaceable class="PARAMETER">table_query</replaceable> <replaceable class="PARAMETER">table_query</replaceable> EXCEPT
<replaceable class="PARAMETER">table_query</replaceable>
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
</synopsis> </synopsis>
...@@ -485,25 +494,25 @@ SELECT f.title, f.did, d.name, f.date_prod, f.kind ...@@ -485,25 +494,25 @@ SELECT f.title, f.did, d.name, f.date_prod, f.kind
FROM distributors d, films f FROM distributors d, films f
WHERE f.did = d.did WHERE f.did = d.did
title |did|name | date_prod|kind title |did|name | date_prod|kind
-------------------------+---+----------------+----------+---------- -------------------------+---+----------------+----------+----------
The Third Man |101|British Lion |1949-12-23|Drama The Third Man |101|British Lion |1949-12-23|Drama
The African Queen |101|British Lion |1951-08-11|Romantic The African Queen |101|British Lion |1951-08-11|Romantic
Une Femme est une Femme |102|Jean Luc Godard |1961-03-12|Romantic Une Femme est une Femme |102|Jean Luc Godard |1961-03-12|Romantic
Vertigo |103|Paramount |1958-11-14|Action Vertigo |103|Paramount |1958-11-14|Action
Becket |103|Paramount |1964-02-03|Drama Becket |103|Paramount |1964-02-03|Drama
48 Hrs |103|Paramount |1982-10-22|Action 48 Hrs |103|Paramount |1982-10-22|Action
War and Peace |104|Mosfilm |1967-02-12|Drama War and Peace |104|Mosfilm |1967-02-12|Drama
West Side Story |105|United Artists |1961-01-03|Musical West Side Story |105|United Artists |1961-01-03|Musical
Bananas |105|United Artists |1971-07-13|Comedy Bananas |105|United Artists |1971-07-13|Comedy
Yojimbo |106|Toho |1961-06-16|Drama Yojimbo |106|Toho |1961-06-16|Drama
There's a Girl in my Soup|107|Columbia |1970-06-11|Comedy There's a Girl in my Soup|107|Columbia |1970-06-11|Comedy
Taxi Driver |107|Columbia |1975-05-15|Action Taxi Driver |107|Columbia |1975-05-15|Action
Absence of Malice |107|Columbia |1981-11-15|Action Absence of Malice |107|Columbia |1981-11-15|Action
Storia di una donna |108|Westward |1970-08-15|Romantic Storia di una donna |108|Westward |1970-08-15|Romantic
The King and I |109|20th Century Fox|1956-08-11|Musical The King and I |109|20th Century Fox|1956-08-11|Musical
Das Boot |110|Bavaria Atelier |1981-11-11|Drama Das Boot |110|Bavaria Atelier |1981-11-11|Drama
Bed Knobs and Broomsticks|111|Walt Disney | |Musical Bed Knobs and Broomsticks|111|Walt Disney | |Musical
</programlisting> </programlisting>
<para> <para>
To sum the column <literal>len</literal> of all films and group To sum the column <literal>len</literal> of all films and group
...@@ -587,14 +596,14 @@ SELECT actors.name ...@@ -587,14 +596,14 @@ SELECT actors.name
FROM actors FROM actors
WHERE actors.name LIKE 'W%' WHERE actors.name LIKE 'W%'
name name
-------------- --------------
Walt Disney Walt Disney
Walter Matthau Walter Matthau
Warner Bros. Warner Bros.
Warren Beatty Warren Beatty
Westward Westward
Woody Allen Woody Allen
</programlisting> </programlisting>
</refsect1> </refsect1>
...@@ -693,85 +702,10 @@ SELECT distributors.* WHERE name = 'Westwood'; ...@@ -693,85 +702,10 @@ SELECT distributors.* WHERE name = 'Westwood';
</refsect1> </refsect1>
</refentry> </refentry>
<refentry id="SQL-SELECTINTO">
<refmeta>
<refentrytitle>
SELECT INTO
</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
SELECT INTO
</refname>
<refpurpose>
Create a new table from an existing table or view
</refpurpose></refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>1998-09-22</date>
</refsynopsisdivinfo>
<synopsis>
SELECT [ ALL | DISTINCT ] <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...]
INTO [TEMP] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ]
[ FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable>] [, ...] ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
[ { UNION [ALL] | INTERSECT | EXCEPT } <replaceable class="PARAMETER">select</replaceable>]
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
[ FOR UPDATE [OF class_name...]]
[ LIMIT count [OFFSET|, count]]
</synopsis>
<refsect2 id="R2-SQL-SELECTINTO-1">
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Inputs
</title>
<para>
All input fields are described in detail for SELECT.
</para>
</refsect2>
<refsect2 id="R2-SQL-SELECTINTO-2">
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Outputs
</title>
<para>
All output fields are described in detail for SELECT.
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-SQL-SELECTINTO-1">
<refsect1info>
<date>1998-09-22</date>
</refsect1info>
<title>
Description
</title>
<para>
SELECT INTO creates a new table from the results of a query. Typically, this
query draws data from an existing table, but any SQL query is allowed.
<note>
<para>
CREATE TABLE AS is functionally equivalent to the SELECT INTO command.
</para>
</note>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag:t sgml-omittag:
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
<refentry id="SQL-SELECTINTO">
<refmeta>
<refentrytitle>
SELECT INTO
</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
SELECT INTO
</refname>
<refpurpose>
Create a new table from an existing table or view
</refpurpose></refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>1998-09-22</date>
</refsynopsisdivinfo>
<synopsis>
SELECT [ ALL | DISTINCT ] <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...]
INTO [TEMP] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ]
[ FROM <replaceable class="PARAMETER">table</replaceable> [<replaceable class="PARAMETER">alias</replaceable>] [, ...] ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
[ { UNION [ALL] | INTERSECT | EXCEPT } <replaceable class="PARAMETER">select</replaceable>]
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
[ FOR UPDATE [OF class_name...]]
[ LIMIT count [OFFSET|, count]]
</synopsis>
<refsect2 id="R2-SQL-SELECTINTO-1">
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Inputs
</title>
<para>
All input fields are described in detail for SELECT.
</para>
</refsect2>
<refsect2 id="R2-SQL-SELECTINTO-2">
<refsect2info>
<date>1998-09-22</date>
</refsect2info>
<title>
Outputs
</title>
<para>
All output fields are described in detail for SELECT.
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-SQL-SELECTINTO-1">
<refsect1info>
<date>1998-09-22</date>
</refsect1info>
<title>
Description
</title>
<para>
SELECT INTO creates a new table from the results of a query. Typically, this
query draws data from an existing table, but any SQL query is allowed.
<note>
<para>
CREATE TABLE AS is functionally equivalent to the SELECT INTO command.
</para>
</note>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:
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:
-->
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
<date>1998-09-24</date> <date>1998-09-24</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
SET <replaceable class="PARAMETER">variable</replaceable> { TO | = } { '<replaceable class="PARAMETER">value</replaceable>' | DEFAULT } SET <replaceable class="PARAMETER">variable</replaceable> { TO | = } {
'<replaceable class="PARAMETER">value</replaceable>' | DEFAULT }
SET TIME ZONE { '<replaceable class="PARAMETER">timezone</replaceable>' | LOCAL | DEFAULT }; SET TIME ZONE { '<replaceable class="PARAMETER">timezone</replaceable>' | LOCAL | DEFAULT };
SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZED } SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZED }
</synopsis> </synopsis>
......
<REFENTRY ID="SQL-SHOW"> <refentry id="SQL-SHOW">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
SHOW SHOW
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
SHOW SHOW
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Shows run-time parameters for session Shows run-time parameters for session
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
SHOW <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> SHOW <replaceable class="PARAMETER">variable</replaceable>
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-SHOW-1"> <refsect2 id="R2-SQL-SHOW-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE>
</TERM>
<LISTITEM>
<PARA>
Refer to <command>SET</command> for more information on available
variables.
</para>
</listitem>
</VARLISTENTRY>
</VARIABLELIST>
</para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-SHOW-2"> <variablelist>
<REFSECT2INFO> <varlistentry>
<DATE>1998-09-24</DATE> <term>
</REFSECT2INFO> <replaceable class="PARAMETER">variable</replaceable>
<TITLE> </term>
Outputs <listitem>
</TITLE> <para>
<PARA> Refer to <command>SET</command> for more information on available
variables.
<VARIABLELIST> </para>
<VARLISTENTRY> </listitem>
<TERM> </varlistentry>
<returnvalue>NOTICE: <REPLACEABLE CLASS="PARAMETER">variable</REPLACEABLE> is <replaceable>value</replaceable></ReturnValue> </variablelist>
SHOW VARIABLE </para>
</TERM> </refsect2>
<LISTITEM>
<PARA>
Message returned if successfully.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
<returnvalue>NOTICE: Unrecognized variable <replaceable>value</replaceable></ReturnValue>
</TERM>
<LISTITEM>
<PARA>
Message returned if <ReturnValue>value</ReturnValue> does not exist.
</PARA>
</LISTITEM>
</VARLISTENTRY>
<VARLISTENTRY>
<TERM>
NOTICE: Time zone is unknown
SHOW VARIABLE
</TERM>
<LISTITEM>
<PARA>
If the TZ environment variable is not set.
</para>
</listitem>
</varlistentry>
</VARIABLELIST>
</para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFSECT1 ID="R1-SQL-SHOW-1"> <refsect2 id="R2-SQL-SHOW-2">
<REFSECT1INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT1INFO> </refsect2info>
<TITLE> <title>
Description Outputs
</TITLE> </title>
<PARA> <para>
<command>SHOW</command> will display the current
configuration parameters for
variable during a session.
</para>
<para>
The session can be configured using <command>SET</command> statement,
and values
can be restored to the defaults using <command>RESET</command> statement.
Parameters and values are case-insensitive.
</para>
<REFSECT2 ID="R2-SQL-SHOW-3"> <variablelist>
<REFSECT2INFO> <varlistentry>
<DATE>1998-09-24</DATE> <term>
</REFSECT2INFO> <returnvalue>NOTICE: <replaceable
<TITLE> class="PARAMETER">">variab</replaceable>E> is <replaceable>value</replaceable></returnvalue>
Notes SHOW VARIABLE
</TITLE> </term>
<PARA> <listitem>
The <command>SHOW</command> is a <productname>Postgres</productname> <para>
language extension. Message returned if successfully.
</para> </para>
<para> </listitem>
Refer to <command>SET</command>/<command>RESET</command> </varlistentry>
to set/reset variable values. <varlistentry>
See also <command>SET TIME ZONE</command>. <term>
</para> <returnvalue>NOTICE: Unrecognized variable <replaceable>value</replaceable></returnvalue>
</REFSECT2> </term>
</REFSECT1> <listitem>
<para>
Message returned if <returnvalue>value</returnvalue> does not exist.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
NOTICE: Time zone is unknown
SHOW VARIABLE
</term>
<listitem>
<para>
If the TZ environment variable is not set.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<REFSECT1 ID="R1-SQL-SHOW-2"> <refsect1 id="R1-SQL-SHOW-1">
<TITLE> <refsect1info>
Usage <date>1998-09-24</date>
</TITLE> </refsect1info>
<PARA> <title>
<ProgramListing> Description
-- show DateStyle; </title>
SHOW DateStyle; <para>
NOTICE:DateStyle is Postgres with US (NonEuropean) conventions <command>SHOW</command> will display the current
configuration parameters for
-- show Geqo; variable during a session.
SHOW GEQO; </para>
NOTICE:GEQO is ON <para>
</ProgramListing> The session can be configured using <command>SET</command> statement,
</para> and values
</REFSECT1> can be restored to the defaults using <command>RESET</command> statement.
Parameters and values are case-insensitive.
</para>
<REFSECT1 ID="R1-SQL-SHOW-3"> <refsect2 id="R2-SQL-SHOW-3">
<TITLE> <refsect2info>
Compatibility <date>1998-09-24</date>
</TITLE> </refsect2info>
<PARA> <title>
</PARA> Notes
</title>
<REFSECT2 ID="R2-SQL-SHOW-4"> <para>
<REFSECT2INFO> The <command>SHOW</command> is a <productname>Postgres</productname>
<DATE>1998-09-24</DATE> language extension.
</REFSECT2INFO> </para>
<TITLE> <para>
SQL92 Refer to <command>SET</command>/<command>RESET</command>
</TITLE> to set/reset variable values.
<PARA> See also <command>SET TIME ZONE</command>.
There is no <command>SET</command> defined in <acronym>SQL92</acronym>. </para>
</para> </refsect2>
</refsect2> </refsect1>
</refsect1>
</REFENTRY> <refsect1 id="R1-SQL-SHOW-2">
<title>
Usage
</title>
<para>
<programlisting>
-- show DateStyle;
SHOW DateStyle;
NOTICE:DateStyle is Postgres with US (NonEuropean) conventions
-- show Geqo;
SHOW GEQO;
NOTICE:GEQO is ON
</programlisting>
</para>
</refsect1>
<refsect1 id="R1-SQL-SHOW-3">
<title>
Compatibility
</title>
<para>
</para>
<refsect2 id="R2-SQL-SHOW-4">
<refsect2info>
<date>1998-09-24</date>
</refsect2info>
<title>
SQL92
</title>
<para>
There is no <command>SHOW</command> defined in <acronym>SQL92</acronym>.
</para>
</refsect2>
</refsect1>
</refentry>
<!-- 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:
-->
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