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