Commit d72168d6 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Complete first pass at markup adjustments for docbook2man man pages.

Add some internal cross references to select.sgml.
parent d289011f
<refentry id="SQL-SELECT"> <refentry id="SQL-SELECT">
<refmeta> <refmeta>
<refentrytitle> <refentrytitle>
SELECT SELECT
</refentrytitle> </refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta> </refmeta>
<refnamediv> <refnamediv>
<refname> <refname>
SELECT SELECT
</refname> </refname>
<refpurpose> <refpurpose>
Retrieve rows from a table or view. Retrieve rows from a table or view.
...@@ -17,20 +17,17 @@ SELECT ...@@ -17,20 +17,17 @@ SELECT
<date>1998-09-24</date> <date>1998-09-24</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] SELECT [ ALL | DISTINCT [ ON <replaceable class="PARAMETER">column</replaceable> ] ]
<replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">expression</replaceable> [ AS <replaceable class="PARAMETER">name</replaceable> ] [, ...]
<replaceable class="PARAMETER">name</replaceable> ] [, ...] [ INTO [ TEMPORARY | TEMP ] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ]
[ INTO [TEMP] [TABLE] <replaceable class="PARAMETER">new_table</replaceable> ] [ FROM <replaceable class="PARAMETER">table</replaceable> [ <replaceable class="PARAMETER">alias</replaceable> ] [, ...] ]
[ FROM <replaceable class="PARAMETER">table</replaceable>
[<replaceable class="PARAMETER">alias</replaceable> ] [, ...] ]
[ WHERE <replaceable class="PARAMETER">condition</replaceable> ] [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
[ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ] [ GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] ]
[ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ] [ HAVING <replaceable class="PARAMETER">condition</replaceable> [, ...] ]
[ { UNION [ALL] | INTERSECT | EXCEPT } <replaceable [ { UNION [ ALL ] | INTERSECT | EXCEPT } <replaceable class="PARAMETER">select</replaceable> ]
class="PARAMETER">select</replaceable> ]
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
[ FOR UPDATE [OF class_name...]] [ FOR UPDATE [ OF class_name... ] ]
[ LIMIT count [OFFSET|, count]] [ LIMIT { count | ALL } [ { OFFSET | , } count ] ]
</synopsis> </synopsis>
<refsect2 id="R2-SQL-SELECT-1"> <refsect2 id="R2-SQL-SELECT-1">
...@@ -40,13 +37,11 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -40,13 +37,11 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
<title> <title>
Inputs Inputs
</title> </title>
<para> <para>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">expression</replaceable></term>
<replaceable class="PARAMETER">expression</replaceable>
</term>
<listitem> <listitem>
<para> <para>
The name of a table's column or an expression. The name of a table's column or an expression.
...@@ -55,9 +50,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -55,9 +50,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">name</replaceable></term>
<replaceable class="PARAMETER">name</replaceable>
</term>
<listitem> <listitem>
<para> <para>
Specifies another name for a column or an expression using Specifies another name for a column or an expression using
...@@ -70,9 +63,8 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -70,9 +63,8 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>TEMPORARY</term>
TEMP <term>TEMP</term>
</term>
<listitem> <listitem>
<para> <para>
The table is created unique to this session, and is The table is created unique to this session, and is
...@@ -82,9 +74,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -82,9 +74,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">new_table</replaceable></term>
<replaceable class="PARAMETER">new_table</replaceable>
</term>
<listitem> <listitem>
<para> <para>
If the INTO TABLE clause is specified, the result of the If the INTO TABLE clause is specified, the result of the
...@@ -105,9 +95,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -105,9 +95,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">table</replaceable></term>
<replaceable class="PARAMETER">table</replaceable>
</term>
<listitem> <listitem>
<para> <para>
The name of an existing table referenced by the FROM clause. The name of an existing table referenced by the FROM clause.
...@@ -116,9 +104,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -116,9 +104,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">alias</replaceable></term>
<replaceable class="PARAMETER">alias</replaceable>
</term>
<listitem> <listitem>
<para> <para>
An alternate name for the preceding An alternate name for the preceding
...@@ -130,9 +116,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -130,9 +116,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">condition</replaceable></term>
<replaceable class="PARAMETER">condition</replaceable>
</term>
<listitem> <listitem>
<para> <para>
A boolean expression giving a result of true or false. A boolean expression giving a result of true or false.
...@@ -142,9 +126,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -142,9 +126,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">column</replaceable></term>
<replaceable class="PARAMETER">column</replaceable>
</term>
<listitem> <listitem>
<para> <para>
The name of a table's column. The name of a table's column.
...@@ -153,9 +135,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -153,9 +135,7 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">select</replaceable></term>
<replaceable class="PARAMETER">select</replaceable>
</term>
<listitem> <listitem>
<para> <para>
A select statement with all features except the ORDER BY clause. A select statement with all features except the ORDER BY clause.
...@@ -175,34 +155,32 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -175,34 +155,32 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
Outputs Outputs
</title> </title>
<para> <para>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>Rows</term>
Rows <listitem>
</term> <para>
<listitem> The complete set of rows resulting from the query specification.
<para> </para>
The complete set of rows resulting from the query specification. </listitem>
</para> </varlistentry>
</listitem>
</varlistentry> <varlistentry>
<term>
<varlistentry> <returnvalue><replaceable>count</replaceable></returnvalue>
<term> </term>
<returnvalue><replaceable>count</replaceable></returnvalue> <listitem>
</term> <para>
<listitem> The count of rows returned by the query.
<para> </para>
The count of rows returned by the query. </listitem>
</para> </varlistentry>
</listitem> </variablelist>
</varlistentry>
</variablelist>
</para> </para>
</refsect2> </refsect2>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1 id="R1-SQL-SELECT-1"> <refsect1 id="R1-SQL-SELECT-1">
<refsect1info> <refsect1info>
<date>1998-09-24</date> <date>1998-09-24</date>
...@@ -213,69 +191,84 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ] ...@@ -213,69 +191,84 @@ SELECT [ALL|DISTINCT [ON <replaceable class="PARAMETER">column</replaceable>] ]
<para> <para>
<command>SELECT</command> will return rows from one or more tables. <command>SELECT</command> will return rows from one or more tables.
Candidates for selection are rows which satisfy the WHERE condition; Candidates for selection are rows which satisfy the WHERE condition;
if WHERE is omitted, all rows are candidates.</para> if WHERE is omitted, all rows are candidates.
(See <xref linkend="where-title" endterm="where-title">.)
</para>
<para> <para>
<command>DISTINCT</command> will eliminate all duplicate rows from the <command>DISTINCT</command> will eliminate all duplicate rows from the
selection. selection.
<command>DISTINCT ON <replaceable class="PARAMETER">column</replaceable></command> will eliminate all duplicates in the specified column; this is <command>DISTINCT ON <replaceable class="PARAMETER">column</replaceable></command>
equivalent to using <command>GROUP BY <replaceable will eliminate all duplicates in the specified column; this is
class="PARAMETER">column</replaceable></command>. <command>ALL</command> will return all candidate rows, equivalent to using
including duplicates.</para> <command>GROUP BY <replaceable class="PARAMETER">column</replaceable></command>.
<command>ALL</command> will return all candidate rows,
including duplicates.
</para>
<para> <para>
The GROUP BY clause allows a user to divide a table The GROUP BY clause allows a user to divide a table
conceptually into groups. (See GROUP BY clause).</para> conceptually into groups.
(See <xref linkend="group-by-title" endterm="group-by-title">.)
</para>
<para> <para>
The HAVING clause specifies a grouped table derived by the The HAVING clause specifies a grouped table derived by the
elimination of groups from the result of the previously elimination of groups from the result of the previously
specified clause. (See HAVING clause).</para> specified clause.
(See <xref linkend="having-title" endterm="having-title">.)
</para>
<para> <para>
The ORDER BY clause allows a user to specify that he/she The ORDER BY clause allows a user to specify that he/she
wishes the rows sorted according to the ASCending or wishes the rows sorted according to the ASCending or
DESCending mode operator. (See ORDER BY clause)</para> DESCending mode operator.
(See <xref linkend="order-by-title" endterm="order-by-title">.)
</para>
<para> <para>
The UNION clause allows the result to be the collection of rows The UNION clause allows the result to be the collection of rows
returned by the queries involved. (See UNION clause).</para> returned by the queries involved.
(See <xref linkend="union-title" endterm="union-title">.)
</para>
<para> <para>
The INTERSECT give you the rows that are common to both queries. The INTERSECT give you the rows that are common to both queries.
(See INTERSECT clause).</para> (See <xref linkend="intersect-title" endterm="intersect-title">.)
</para>
<para> <para>
The EXCEPT give you the rows in the upper query not in the lower query. The EXCEPT give you the rows in the upper query not in the lower query.
(See EXCEPT clause).</para> (See <xref linkend="except-title" endterm="except-title">.)
</para>
<para> <para>
The FOR UPDATE clause allows the SELECT statement to perform The FOR UPDATE clause allows the SELECT statement to perform
exclusive locking of selected rows. exclusive locking of selected rows.
(See EXCEPT clause).</para> </para>
<para> <para>
The LIMIT...OFFSET clause allows control over which rows are The LIMIT...OFFSET clause allows control over which rows are
returned by the query.</para> returned by the query.
</para>
<para> <para>
You must have SELECT privilege to a table to read its values You must have SELECT privilege to a table to read its values
(See <command>GRANT</command>/<command>REVOKE</command> statements). (See the <command>GRANT</command>/<command>REVOKE</command> statements).
</para> </para>
<refsect2 id="R2-SQL-WHERE-2"> <refsect2 id="R2-SQL-WHERE-2">
<refsect2info> <refsect2info>
<date>1998-09-24</date> <date>1998-09-24</date>
</refsect2info> </refsect2info>
<title> <title id="where-title">
WHERE Clause WHERE Clause
</title> </title>
<para> <para>
The optional WHERE condition has the general form: The optional WHERE condition has the general form:
<synopsis> <synopsis>
WHERE <replaceable class="PARAMETER">expr</replaceable> <replaceable 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> ... ]
class="PARAMETER">ETER">c</replaceable>e<replaceable class="PARAMETER">"PAR</replaceable>replaceable> [ <replaceable
class="PARAMETER">log_op</replaceable> ... ]
</synopsis> </synopsis>
where <replaceable class="PARAMETER">cond_op</replaceable> can be where <replaceable class="PARAMETER">cond_op</replaceable> can be
...@@ -294,7 +287,7 @@ class="PARAMETER">log_op</replaceable> ... ] ...@@ -294,7 +287,7 @@ class="PARAMETER">log_op</replaceable> ... ]
<refsect2info> <refsect2info>
<date>1998-09-24</date> <date>1998-09-24</date>
</refsect2info> </refsect2info>
<title> <title id="group-by-title">
GROUP BY Clause GROUP BY Clause
</title> </title>
<para> <para>
...@@ -302,19 +295,24 @@ class="PARAMETER">log_op</replaceable> ... ] ...@@ -302,19 +295,24 @@ class="PARAMETER">log_op</replaceable> ... ]
of this clause: of this clause:
<synopsis> <synopsis>
GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...] GROUP BY <replaceable class="PARAMETER">column</replaceable> [, ...]
</synopsis></para> </synopsis>
<para> </para>
GROUP BY will condense into a single row all rows that share the same values for the
grouped columns; aggregates return values derived from all rows that make up the group. The value returned for an ungrouped <para>
and unaggregated column is dependent on the order in which rows happen to be read from the database. GROUP BY will condense into a single row all rows that share the
</para> same values for the
</refsect2> grouped columns; aggregates return values derived from all rows
that make up the group. The value returned for an ungrouped
and unaggregated column is dependent on the order in which rows
happen to be read from the database.
</para>
</refsect2>
<refsect2 id="R2-SQL-HAVING-2"> <refsect2 id="R2-SQL-HAVING-2">
<refsect2info> <refsect2info>
<date>1998-09-24</date> <date>1998-09-24</date>
</refsect2info> </refsect2info>
<title> <title id="having-title">
HAVING Clause HAVING Clause
</title> </title>
<para> <para>
...@@ -325,16 +323,17 @@ HAVING <replaceable class="PARAMETER">cond_expr</replaceable> ...@@ -325,16 +323,17 @@ HAVING <replaceable class="PARAMETER">cond_expr</replaceable>
</synopsis> </synopsis>
where <replaceable class="PARAMETER">cond_expr</replaceable> is the same where <replaceable class="PARAMETER">cond_expr</replaceable> is the same
as specified for the WHERE clause.</para> as specified for the WHERE clause.
</para>
<para> <para>
HAVING specifies a grouped table derived by the elimination HAVING specifies a grouped table derived by the elimination
of groups from the result of the previously specified clause of groups from the result of the previously specified clause
that do not meet the <replaceable class="PARAMETER">cond_expr</replaceable>.</para> that do not meet the <replaceable class="PARAMETER">cond_expr</replaceable>.</para>
<para> <para>
Each column referenced in Each column referenced in
<replaceable class="PARAMETER">cond_expr</replaceable> shall unambiguously <replaceable class="PARAMETER">cond_expr</replaceable> shall unambiguously
reference a grouping column. reference a grouping column.
</para> </para>
</refsect2> </refsect2>
...@@ -343,7 +342,7 @@ HAVING <replaceable class="PARAMETER">cond_expr</replaceable> ...@@ -343,7 +342,7 @@ HAVING <replaceable class="PARAMETER">cond_expr</replaceable>
<refsect2info> <refsect2info>
<date>1998-09-24</date> <date>1998-09-24</date>
</refsect2info> </refsect2info>
<title> <title id="order-by-title">
ORDER BY Clause ORDER BY Clause
</title> </title>
<para> <para>
...@@ -353,7 +352,8 @@ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, . ...@@ -353,7 +352,8 @@ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, .
<para> <para>
<replaceable class="PARAMETER">column</replaceable> can be either a column <replaceable class="PARAMETER">column</replaceable> can be either a column
name or an ordinal number.</para> name or an ordinal number.
</para>
<para> <para>
The ordinal numbers refers to the ordinal (left-to-right) position The ordinal numbers refers to the ordinal (left-to-right) position
of the column. This feature makes it possible to define an ordering of the column. This feature makes it possible to define an ordering
...@@ -366,130 +366,136 @@ SELECT title, date_prod + 1 AS newlen FROM films ORDER BY newlen; ...@@ -366,130 +366,136 @@ SELECT title, date_prod + 1 AS newlen FROM films ORDER BY newlen;
</programlisting></para> </programlisting></para>
<para> <para>
From release 6.4 of PostgreSQL, the columns in the ORDER BY clause do not need to appear in the SELECT clause. From release 6.4 of PostgreSQL, the columns in the ORDER BY clause
do not need to appear in the SELECT clause.
Thus the following statement is now legal: Thus the following statement is now legal:
<programlisting> <programlisting>
SELECT name FROM distributors ORDER BY code; SELECT name FROM distributors ORDER BY code;
</programlisting></para> </programlisting>
</para>
<para> <para>
Optionally one may add the keyword DESC (descending) Optionally one may add the keyword DESC (descending)
or ASC (ascending) after each column name in the ORDER BY clause. or ASC (ascending) after each column name in the ORDER BY clause.
If not specified, ASC is assumed by default.</para> If not specified, ASC is assumed by default.
</para>
</refsect2> </refsect2>
<refsect2 id="R2-SQL-UNION-2"> <refsect2 id="R2-SQL-UNION-2">
<refsect2info> <refsect2info>
<date>1998-09-24</date> <date>1998-09-24</date>
</refsect2info> </refsect2info>
<title> <title id="union-title">
UNION Clause UNION Clause
</title> </title>
<para> <para>
<synopsis> <synopsis>
<replaceable class="PARAMETER">table_query</replaceable> UNION [ ALL ] <replaceable class="PARAMETER">table_query</replaceable> UNION [ ALL ] <replaceable class="PARAMETER">table_query</replaceable>
<replaceable class="PARAMETER">table_query</replaceable> [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
</synopsis> </synopsis>
where where
<replaceable class="PARAMETER">table_query</replaceable> <replaceable class="PARAMETER">table_query</replaceable>
specifies any select expression without an ORDER BY clause.</para> specifies any select expression without an ORDER BY clause.
</para>
<para> <para>
The UNION clause allows the result to be the collection of rows The UNION clause allows the result to be the collection of rows
returned by the queries involved. (See UNION clause). returned by the queries involved. (See UNION clause).
The two tables that represent the direct operands of the UNION must The two tables that represent the direct operands of the UNION must
have the same number of columns, and corresponding columns must be have the same number of columns, and corresponding columns must be
of compatible data types.</para> of compatible data types.
</para>
<para> <para>
By default, the result of UNION does not contain any duplicate rows By default, the result of UNION does not contain any duplicate rows
unless the ALL clause is specified.</para> unless the ALL clause is specified.
</para>
<para> <para>
Multiple UNION operators in the same SELECT statement are Multiple UNION operators in the same SELECT statement are
evaluated left to right. evaluated left to right.
Note that the ALL keyword is not global in nature, being Note that the ALL keyword is not global in nature, being
applied only for the current pair of table results.</para> applied only for the current pair of table results.
</para>
</refsect2> </refsect2>
<refsect2 id="R2-SQL-INTERSECT-2"> <refsect2 id="R2-SQL-INTERSECT-2">
<refsect2info> <refsect2info>
<date>1998-09-24</date> <date>1998-09-24</date>
</refsect2info> </refsect2info>
<title> <title id="intersect-title">
INTERSECT Clause INTERSECT Clause
</title> </title>
<para> <para>
<synopsis> <synopsis>
<replaceable class="PARAMETER">table_query</replaceable> INTERSECT <replaceable class="PARAMETER">table_query</replaceable> INTERSECT <replaceable class="PARAMETER">table_query</replaceable>
<replaceable class="PARAMETER">table_query</replaceable> [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
</synopsis> </synopsis>
where where
<replaceable class="PARAMETER">table_query</replaceable> <replaceable class="PARAMETER">table_query</replaceable>
specifies any select expression without an ORDER BY clause.</para> specifies any select expression without an ORDER BY clause.
</para>
<para> <para>
The INTERSECT clause allows the result to be all rows that are The INTERSECT clause allows the result to be all rows that are
common to the involved queries. (See INTERSECT clause). common to the involved queries.
The two tables that represent the direct operands of the INTERSECT must The two tables that represent the direct operands of the INTERSECT must
have the same number of columns, and corresponding columns must be have the same number of columns, and corresponding columns must be
of compatible data types.</para> of compatible data types.
</para>
<para> <para>
Multiple INTERSECT operators in the same SELECT statement are Multiple INTERSECT operators in the same SELECT statement are
evaluated left to right. evaluated left to right.
</para> </para>
</refsect2> </refsect2>
<refsect2 id="R2-SQL-EXCEPT-2"> <refsect2 id="R2-SQL-EXCEPT-2">
<refsect2info> <refsect2info>
<date>1998-09-24</date> <date>1998-09-24</date>
</refsect2info> </refsect2info>
<title> <title id="except-title">
EXCEPT Clause EXCEPT Clause
</title> </title>
<para> <para>
<synopsis> <synopsis>
<replaceable class="PARAMETER">table_query</replaceable> EXCEPT <replaceable class="PARAMETER">table_query</replaceable> EXCEPT <replaceable class="PARAMETER">table_query</replaceable>
<replaceable class="PARAMETER">table_query</replaceable>
[ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ] [ ORDER BY <replaceable class="PARAMETER">column</replaceable> [ ASC | DESC ] [, ...] ]
</synopsis> </synopsis>
where where
<replaceable class="PARAMETER">table_query</replaceable> <replaceable class="PARAMETER">table_query</replaceable>
specifies any select expression without an ORDER BY clause.</para> specifies any select expression without an ORDER BY clause.
</para>
<para> <para>
The EXCEPT clause allows the result to be rows from the upper query The EXCEPT clause allows the result to be rows from the upper query
that are not in the lower query. (See EXCEPT clause). that are not in the lower query. (See EXCEPT clause).
The two tables that represent the direct operands of the EXCEPT must The two tables that represent the direct operands of the EXCEPT must
have the same number of columns, and corresponding columns must be have the same number of columns, and corresponding columns must be
of compatible data types.</para> of compatible data types.
</para>
<para> <para>
Multiple EXCEPT operators in the same SELECT statement are Multiple EXCEPT operators in the same SELECT statement are
evaluated left to right. evaluated left to right.
</para> </para>
</refsect2> </refsect2>
</refsect1>
</refsect1>
<refsect1 id="R1-SQL-SELECT-2"> <refsect1 id="R1-SQL-SELECT-2">
<title> <title>
Usage Usage
</title> </title>
<para> <para>
To join the table <literal>films</literal> with the table To join the table <literal>films</literal> with the table
<literal>distributors</literal>: <literal>distributors</literal>:
</para>
<programlisting> <programlisting>
SELECT f.title, f.did, d.name, f.date_prod, f.kind SELECT f.title, f.did, d.name, f.date_prod, f.kind
FROM distributors d, films f FROM distributors d, films f
WHERE f.did = d.did WHERE f.did = d.did
...@@ -513,12 +519,14 @@ Storia di una donna |108|Westward |1970-08-15|Romantic ...@@ -513,12 +519,14 @@ Storia di una donna |108|Westward |1970-08-15|Romantic
The King and I |109|20th Century Fox|1956-08-11|Musical The King and I |109|20th Century Fox|1956-08-11|Musical
Das Boot |110|Bavaria Atelier |1981-11-11|Drama Das Boot |110|Bavaria Atelier |1981-11-11|Drama
Bed Knobs and Broomsticks|111|Walt Disney | |Musical Bed Knobs and Broomsticks|111|Walt Disney | |Musical
</programlisting> </programlisting>
</para>
<para> <para>
To sum the column <literal>len</literal> of all films and group To sum the column <literal>len</literal> of all films and group
the results by <literal>kind</literal>: the results by <literal>kind</literal>:
</para>
<programlisting> <programlisting>
SELECT kind, SUM(len) AS total FROM films GROUP BY kind; SELECT kind, SUM(len) AS total FROM films GROUP BY kind;
kind |total kind |total
...@@ -528,14 +536,15 @@ SELECT kind, SUM(len) AS total FROM films GROUP BY kind; ...@@ -528,14 +536,15 @@ SELECT kind, SUM(len) AS total FROM films GROUP BY kind;
Drama | 14:28 Drama | 14:28
Musical | 06:42 Musical | 06:42
Romantic | 04:38 Romantic | 04:38
</programlisting> </programlisting>
</para>
<para> <para>
To sum the column <literal>len</literal> of all films, group To sum the column <literal>len</literal> of all films, group
the results by <literal>kind</literal> and show those group totals the results by <literal>kind</literal> and show those group totals
that are less than 5 hours: that are less than 5 hours:
</para>
<programlisting> <programlisting>
SELECT kind, SUM(len) AS total SELECT kind, SUM(len) AS total
FROM films FROM films
GROUP BY kind GROUP BY kind
...@@ -545,13 +554,15 @@ SELECT kind, SUM(len) AS total ...@@ -545,13 +554,15 @@ SELECT kind, SUM(len) AS total
----------+------ ----------+------
Comedy | 02:58 Comedy | 02:58
Romantic | 04:38 Romantic | 04:38
</programlisting> </programlisting>
</para>
<para> <para>
The following two examples are identical ways of sorting the individual The following two examples are identical ways of sorting the individual
results according to the contents of the second column results according to the contents of the second column
(<literal>name</literal>): (<literal>name</literal>):
</para>
<programlisting> <programlisting>
SELECT * FROM distributors ORDER BY name; SELECT * FROM distributors ORDER BY name;
SELECT * FROM distributors ORDER BY 2; SELECT * FROM distributors ORDER BY 2;
...@@ -570,7 +581,8 @@ SELECT * FROM distributors ORDER BY 2; ...@@ -570,7 +581,8 @@ SELECT * FROM distributors ORDER BY 2;
111|Walt Disney 111|Walt Disney
112|Warner Bros. 112|Warner Bros.
108|Westward 108|Westward
</programlisting> </programlisting>
</para>
<para> <para>
This example shows how to obtain the union of the tables This example shows how to obtain the union of the tables
...@@ -578,8 +590,8 @@ SELECT * FROM distributors ORDER BY 2; ...@@ -578,8 +590,8 @@ SELECT * FROM distributors ORDER BY 2;
<literal>actors</literal>, restricting the results to those that begin <literal>actors</literal>, restricting the results to those that begin
with letter W in each table. Only distinct rows are to be used, so the with letter W in each table. Only distinct rows are to be used, so the
ALL keyword is omitted: ALL keyword is omitted:
</para>
<programlisting> <programlisting>
-- distributors: actors: -- distributors: actors:
-- did|name id|name -- did|name id|name
-- ---+------------ --+-------------- -- ---+------------ --+--------------
...@@ -604,8 +616,8 @@ Warner Bros. ...@@ -604,8 +616,8 @@ Warner Bros.
Warren Beatty Warren Beatty
Westward Westward
Woody Allen Woody Allen
</programlisting> </programlisting>
</para>
</refsect1> </refsect1>
<refsect1 id="R1-SQL-SELECT-3"> <refsect1 id="R1-SQL-SELECT-3">
...@@ -705,7 +717,7 @@ SELECT distributors.* WHERE name = 'Westwood'; ...@@ -705,7 +717,7 @@ SELECT distributors.* WHERE name = 'Westwood';
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag: sgml-omittag:nil
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
<refentry id="SQL-SELECTINTO"> <refentry id="SQL-SELECTINTO">
<refmeta> <refmeta>
<refentrytitle> <refentrytitle>
SELECT INTO SELECT INTO
</refentrytitle> </refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta> </refmeta>
<refnamediv> <refnamediv>
<refname> <refname>
SELECT INTO SELECT INTO
</refname> </refname>
<refpurpose> <refpurpose>
Create a new table from an existing table or view Create a new table from an existing table or view
</refpurpose></refnamediv> </refpurpose></refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<refsynopsisdivinfo> <refsynopsisdivinfo>
...@@ -37,7 +37,8 @@ SELECT [ ALL | DISTINCT ] <replaceable class="PARAMETER">expression</replaceable ...@@ -37,7 +37,8 @@ SELECT [ ALL | DISTINCT ] <replaceable class="PARAMETER">expression</replaceable
Inputs Inputs
</title> </title>
<para> <para>
All input fields are described in detail for SELECT. All input fields are described in detail for
<xref linkend="select-title" endterm="select-title">.
</para> </para>
</refsect2> </refsect2>
...@@ -49,7 +50,8 @@ All input fields are described in detail for SELECT. ...@@ -49,7 +50,8 @@ All input fields are described in detail for SELECT.
Outputs Outputs
</title> </title>
<para> <para>
All output fields are described in detail for SELECT. All output fields are described in detail for
<xref linkend="select-title" endterm="select-title">.
</para> </para>
</refsect2> </refsect2>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -62,12 +64,14 @@ All output fields are described in detail for SELECT. ...@@ -62,12 +64,14 @@ All output fields are described in detail for SELECT.
Description Description
</title> </title>
<para> <para>
SELECT INTO creates a new table from the results of a query. Typically, this <command>SELECT INTO</command> 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. query draws data from an existing table, but any SQL query is allowed.
<note> <note>
<para> <para>
CREATE TABLE AS is functionally equivalent to the SELECT INTO command. CREATE TABLE AS is functionally equivalent to the SELECT INTO command.
</para> </para>
</note> </note>
</para> </para>
</refsect1> </refsect1>
...@@ -76,7 +80,7 @@ All output fields are described in detail for SELECT. ...@@ -76,7 +80,7 @@ All output fields are described in detail for SELECT.
<!-- Keep this comment at the end of the file <!-- Keep this comment at the end of the file
Local variables: Local variables:
mode: sgml mode: sgml
sgml-omittag: sgml-omittag:nil
sgml-shorttag:t sgml-shorttag:t
sgml-minimize-attributes:nil sgml-minimize-attributes:nil
sgml-always-quote-attributes:t sgml-always-quote-attributes:t
......
...@@ -201,9 +201,9 @@ default ...@@ -201,9 +201,9 @@ default
Setting the <envar>PGDATESTYLE</envar> environment variable. Setting the <envar>PGDATESTYLE</envar> environment variable.
</member> </member>
<member> <member>
Running postmaster using the <option>-oe</option> parameter to set Running postmaster using the option <option>-o -e</option> to set
dates to the <literal>European</literal> convention. dates to the <literal>European</literal> convention.
Note that this affects only the some combinations of date styles; for example Note that this affects only some combinations of date styles; for example
the ISO style is not affected by this parameter. the ISO style is not affected by this parameter.
</member> </member>
<member> <member>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<date>1998-09-24</date> <date>1998-09-24</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
SHOW <replaceable class="PARAMETER">variable</replaceable> SHOW <replaceable class="PARAMETER">keyword</replaceable>
</synopsis> </synopsis>
<refsect2 id="R2-SQL-SHOW-1"> <refsect2 id="R2-SQL-SHOW-1">
...@@ -28,17 +28,15 @@ SHOW <replaceable class="PARAMETER">variable</replaceable> ...@@ -28,17 +28,15 @@ SHOW <replaceable class="PARAMETER">variable</replaceable>
<title> <title>
Inputs Inputs
</title> </title>
<para>
<para>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term><replaceable class="PARAMETER">keyword</replaceable></term>
<replaceable class="PARAMETER">variable</replaceable>
</term>
<listitem> <listitem>
<para> <para>
Refer to <command>SET</command> for more information on available Refer to <command>SET</command> for more information on available
variables. arguments.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -53,40 +51,40 @@ SHOW <replaceable class="PARAMETER">variable</replaceable> ...@@ -53,40 +51,40 @@ SHOW <replaceable class="PARAMETER">variable</replaceable>
<title> <title>
Outputs Outputs
</title> </title>
<para>
<para>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term><computeroutput>
<returnvalue>NOTICE: <replaceable NOTICE: <replaceable class="PARAMETER">variable</replaceable> is <replaceable>value</replaceable>
class="PARAMETER">">variab</replaceable>E> is <replaceable>value</replaceable></returnvalue> SHOW VARIABLE
SHOW VARIABLE </computeroutput></term>
</term>
<listitem> <listitem>
<para> <para>
Message returned if successfully. Message returned if successful.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><computeroutput>
<returnvalue>NOTICE: Unrecognized variable <replaceable>value</replaceable></returnvalue> NOTICE: Unrecognized variable <replaceable>value</replaceable>
</term> </computeroutput></term>
<listitem> <listitem>
<para> <para>
Message returned if <returnvalue>value</returnvalue> does not exist. Message returned if <returnvalue>value</returnvalue> does not exist.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><computeroutput>
NOTICE: Time zone is unknown NOTICE: Time zone is unknown
SHOW VARIABLE SHOW VARIABLE
</term> </computeroutput></term>
<listitem> <listitem>
<para> <para>
If the TZ environment variable is not set. If the <envar>TZ</envar> or <envar>PGTZ</envar> environment
variable is not set.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -138,12 +136,17 @@ SHOW <replaceable class="PARAMETER">variable</replaceable> ...@@ -138,12 +136,17 @@ SHOW <replaceable class="PARAMETER">variable</replaceable>
Usage Usage
</title> </title>
<para> <para>
Show the current <literal>DateStyle</literal> setting:
<programlisting> <programlisting>
-- show DateStyle;
SHOW DateStyle; SHOW DateStyle;
NOTICE:DateStyle is Postgres with US (NonEuropean) conventions NOTICE:DateStyle is Postgres with US (NonEuropean) conventions
</programlisting>
</para>
-- show Geqo; <para>
Show the current genetic optimizer (<literal>geqo</literal>) setting:
<programlisting>
SHOW GEQO; SHOW GEQO;
NOTICE:GEQO is ON NOTICE:GEQO is ON
</programlisting> </programlisting>
...@@ -183,7 +186,7 @@ sgml-indent-data:t ...@@ -183,7 +186,7 @@ sgml-indent-data:t
sgml-parent-document:nil sgml-parent-document:nil
sgml-default-dtd-file:"../reference.ced" sgml-default-dtd-file:"../reference.ced"
sgml-exposed-tags:nil sgml-exposed-tags:nil
sgml-local-catalogs:"/usr/lib/sgml/CATALOG" sgml-local-catalogs:"/usr/lib/sgml/catalog"
sgml-local-ecat-files:nil sgml-local-ecat-files:nil
End: End:
--> -->
<REFENTRY ID="SQL-UNLISTEN"> <refentry id="SQL-UNLISTEN">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
UNLISTEN UNLISTEN
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
UNLISTEN UNLISTEN
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Stop listening for notification Stop listening for notification
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-10-19</DATE> <date>1998-10-19</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
UNLISTEN { <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE> | * } UNLISTEN { <replaceable class="PARAMETER">notifyname</replaceable> | * }
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-UNLISTEN-1"> <refsect2 id="R2-SQL-UNLISTEN-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-10-19</DATE> <date>1998-10-19</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA>
</PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term><replaceable class="PARAMETER">notifyname</replaceable></term>
<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE> <listitem>
</TERM> <para>
<LISTITEM> Name of previously registered notify condition.
<PARA> </para>
Name of previously registered notify condition. </listitem>
</para> </varlistentry>
</listitem> <varlistentry>
</varlistentry> <term><literal>*</literal></term>
<VARLISTENTRY> <listitem>
<TERM> <para>
<literal>*</literal> All current listen registrations for this backend are cleared.
</TERM> </para>
<LISTITEM> </listitem>
<PARA> </varlistentry>
All current listen registrations for this backend are cleared. </variablelist>
</para> </para>
</listitem> </refsect2>
</varlistentry>
<refsect2 id="R2-SQL-UNLISTEN-2">
</VARIABLELIST> <refsect2info>
<date>1998-10-19</date>
</REFSECT2> </refsect2info>
<title>
<REFSECT2 ID="R2-SQL-UNLISTEN-2"> Outputs
<REFSECT2INFO> </title>
<DATE>1998-10-19</DATE> <para>
</REFSECT2INFO>
<TITLE> <variablelist>
Outputs <varlistentry>
</TITLE> <term><computeroutput>
<PARA>
<VARIABLELIST>
<VARLISTENTRY>
<TERM>
<returnvalue>UNLISTEN</returnvalue> <returnvalue>UNLISTEN</returnvalue>
</TERM> </computeroutput></term>
<LISTITEM> <listitem>
<PARA> <para>
Acknowledgement that statement has executed. Acknowledgement that statement has executed.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist>
</VARIABLELIST> </para>
</para> </refsect2>
</REFSECT2> </refsynopsisdiv>
</REFSYNOPSISDIV>
<refsect1 id="R1-SQL-UNLISTEN-1">
<REFSECT1 ID="R1-SQL-UNLISTEN-1"> <refsect1info>
<REFSECT1INFO> <date>1998-10-19</date>
<DATE>1998-10-19</DATE> </refsect1info>
</REFSECT1INFO> <title>
<TITLE> Description
Description </title>
</TITLE>
<PARA> <para>
<command>UNLISTEN</command> <command>UNLISTEN</command>
is used to remove an existing <command>NOTIFY</command> registration. is used to remove an existing <command>NOTIFY</command> registration.
UNLISTEN cancels any existing registration of the current UNLISTEN cancels any existing registration of the current
<productname>Postgres</productname> session as a listener on the notify <productname>Postgres</productname> session as a listener on the notify
condition <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>. condition <replaceable class="PARAMETER">notifyname</replaceable>.
The special condition wildcard "*" cancels all listener registrations The special condition wildcard "*" cancels all listener registrations
for the current session. for the current session.
</para> </para>
<para>
<xref linkend="sql-notify" endterm="sql-notify-ref"> <para>
contains a more extensive <xref endterm="sql-notify-ref" linkend="sql-notify">
discussion of the use of <command>LISTEN</command> and contains a more extensive
<command>NOTIFY</command>. discussion of the use of <command>LISTEN</command> and
</para> <command>NOTIFY</command>.
</para>
<REFSECT2 ID="R2-SQL-UNLISTEN-3">
<REFSECT2INFO> <refsect2 id="R2-SQL-UNLISTEN-3">
<DATE>1998-10-19</DATE> <refsect2info>
</REFSECT2INFO> <date>1998-10-19</date>
<TITLE> </refsect2info>
Notes <title>
</TITLE> Notes
<para> </title>
<REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE> <para>
needs not to be a valid class name but can be any string valid <replaceable class="PARAMETER">classname</replaceable>
as a name up to 32 characters long. needs not to be a valid class name but can be any string valid
</para> as a name up to 32 characters long.
<para> </para>
The backend does not complain if you UNLISTEN something you were not <para>
listening for. The backend does not complain if you UNLISTEN something you were not
Each backend will automatically execute <command>UNLISTEN *</command> when listening for.
exiting. Each backend will automatically execute <command>UNLISTEN *</command> when
</para> exiting.
<para> </para>
A restriction in some previous releases of <para>
<productname>Postgres</productname> that a A restriction in some previous releases of
<REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE> <productname>Postgres</productname> that a
which does not correspond to an actual table must be enclosed in double-quotes <replaceable class="PARAMETER">classname</replaceable>
is no longer present. which does not correspond to an actual table must be enclosed in double-quotes
</para> is no longer present.
</REFSECT2> </para>
</refsect1> </refsect2>
</refsect1>
<REFSECT1 ID="R1-SQL-UNLISTEN-2">
<TITLE> <refsect1 id="R1-SQL-UNLISTEN-2">
Usage <title>
</TITLE> Usage
</title>
<para>
<programlisting> <para>
To subscribe to an existing registration:
<programlisting>
postgres=> LISTEN virtual; postgres=> LISTEN virtual;
LISTEN LISTEN
postgres=> NOTIFY virtual; postgres=> NOTIFY virtual;
NOTIFY NOTIFY
ASYNC NOTIFY of 'virtual' from backend pid '12317' received ASYNC NOTIFY of 'virtual' from backend pid '12317' received
</programlisting> </programlisting>
</para>
<programlisting> <para>
Once UNLISTEN has been executed, further NOTIFY commands will be
ignored:
<programlisting>
postgres=> UNLISTEN virtual; postgres=> UNLISTEN virtual;
UNLISTEN UNLISTEN
postgres=> NOTIFY virtual; postgres=> NOTIFY virtual;
NOTIFY NOTIFY
-- notice no NOTIFY event is received -- notice no NOTIFY event is received
postgres=> </programlisting>
</programlisting> </para>
</para> </refsect1>
</REFSECT1>
<refsect1 id="R1-SQL-UNLISTEN-3">
<REFSECT1 ID="R1-SQL-UNLISTEN-3"> <title>
<TITLE> Compatibility
Compatibility </title>
</TITLE>
<refsect2 id="R2-SQL-UNLISTEN-4">
<REFSECT2 ID="R2-SQL-UNLISTEN-4"> <refsect2info>
<REFSECT2INFO> <date>1998-10-19</date>
<DATE>1998-10-19</DATE> </refsect2info>
</REFSECT2INFO> <title>
<TITLE> SQL92
SQL92 </title>
</TITLE> <para>
<PARA> There is no <command>UNLISTEN</command> in <acronym>SQL92</acronym>.
There is no <command>UNLISTEN</command> in <acronym>SQL92</acronym>. </para>
</para> </refsect2>
</refsect2> </refsect1>
</refsect1> </refentry>
</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-UPDATE"> <refentry id="SQL-UPDATE">
<REFMETA> <refmeta>
<REFENTRYTITLE> <refentrytitle>
UPDATE UPDATE
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
UPDATE UPDATE
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Replaces values of columns in a table Replaces values of columns in a table
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
UPDATE <REPLACEABLE CLASS="PARAMETER">table</replaceable> SET <REPLACEABLE CLASS="PARAMETER">column</replaceable> = <REPLACEABLE CLASS="PARAMETER">expression</replaceable> [, ...] UPDATE <replaceable class="PARAMETER">table</replaceable> SET <replaceable class="PARAMETER">R">col</replaceable>le> = <replaceable class="PARAMETER">expression</replaceable> [, ...]
[ FROM <REPLACEABLE CLASS="PARAMETER">fromlist</REPLACEABLE> ] [ FROM <replaceable class="PARAMETER">fromlist</replaceable> ]
[ WHERE <REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE> ] [ WHERE <replaceable class="PARAMETER">condition</replaceable> ]
</SYNOPSIS> </synopsis>
<REFSECT2 ID="R2-SQL-UPDATE-1"> <refsect2 id="R2-SQL-UPDATE-1">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
Inputs Inputs
</TITLE> </title>
<PARA> <para>
<VARIABLELIST> <variablelist>
<VARLISTENTRY> <varlistentry>
<TERM> <term><replaceable class="PARAMETER">table</replaceable></term>
<REPLACEABLE CLASS="PARAMETER">table</replaceable> <listitem>
</TERM> <para>
<LISTITEM> The name of an existing table.
<PARA> </para>
The name of an existing table. </listitem>
</para> </varlistentry>
</LISTITEM> <varlistentry>
</VARLISTENTRY> <term><replaceable class="PARAMETER">column</replaceable></term>
<VARLISTENTRY> <listitem>
<TERM> <para>
<REPLACEABLE CLASS="PARAMETER">column</replaceable> The name of a column in <replaceable class="PARAMETER">table</replaceable>.
</TERM> </para>
<LISTITEM> </listitem>
<PARA> </varlistentry>
The name of a column in <REPLACEABLE CLASS="PARAMETER">table</replaceable>. <varlistentry>
</para> <term><replaceable class="PARAMETER">expression</replaceable></term>
</LISTITEM> <listitem>
</VARLISTENTRY> <para>
<VARLISTENTRY> A valid expression or value to assign to column.
<TERM> </para>
<REPLACEABLE CLASS="PARAMETER">expression</replaceable> </listitem>
</TERM> </varlistentry>
<LISTITEM> <varlistentry>
<PARA> <term><replaceable class="PARAMETER">fromlist</replaceable></term>
A valid expression or value to assign to column. <listitem>
</para> <para>
</LISTITEM> A <productname>Postgres</productname>
</VARLISTENTRY> non-standard extension to allow columns
<VARLISTENTRY> from other tables to appear in the WHERE condition.
<TERM> </para>
<REPLACEABLE CLASS="PARAMETER">fromlist</REPLACEABLE> </listitem>
</TERM> </varlistentry>
<LISTITEM> <varlistentry>
<PARA> <term><replaceable class="PARAMETER">condition</replaceable></term>
A <productname>Postgres</productname> <listitem>
non-standard extension to allow columns <para>
from other tables to appear in the WHERE condition. Refer to the SELECT statement for a further description
</para> of the WHERE clause.
</LISTITEM> </para>
</VARLISTENTRY> </listitem>
<VARLISTENTRY> </varlistentry>
<TERM> </variablelist>
<REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE> </para>
</TERM> </refsect2>
<LISTITEM>
<PARA> <refsect2 id="R2-SQL-UPDATE-2">
Refer to the SELECT statement for a further description <refsect2info>
of the WHERE clause. <date>1998-09-24</date>
</para> </refsect2info>
</LISTITEM> <title>
</VARLISTENTRY> Outputs
</VARIABLELIST> </title>
</para>
</REFSECT2> <para>
<variablelist>
<REFSECT2 ID="R2-SQL-UPDATE-2"> <varlistentry>
<REFSECT2INFO> <term><computeroutput>
<DATE>1998-09-24</DATE> UPDATE <replaceable class="parameter">#</replaceable>
</REFSECT2INFO> </computeroutput></term>
<TITLE> <listitem>
Outputs <para>
</TITLE> Message returned if successful.
<PARA> The <replaceable class="parameter">#</replaceable>
means the number of rows updated.
<VARIABLELIST> If <replaceable class="parameter">#</replaceable>
<VARLISTENTRY> is equal 0 no rows are updated.
<TERM> </para>
UPDATE <replaceable class="parameter">#</replaceable> </listitem>
</TERM> </varlistentry>
<LISTITEM> </variablelist>
<PARA> </para>
Message returned if successful. </refsect2>
The <replaceable class="parameter">#</replaceable> </refsynopsisdiv>
means the number of rows updated.
If <replaceable class="parameter">#</replaceable> <refsect1 id="R1-SQL-UPDATE-1">
is equal 0 no rows are updated. <refsect1info>
</para> <date>1998-09-24</date>
</LISTITEM> </refsect1info>
</VARLISTENTRY> <title>
</VARIABLELIST> Description
</para> </title>
</REFSECT2> <para>
</REFSYNOPSISDIV> <command>UPDATE</command> changes the values of the columns specified for
all rows which satisfy condition. Only the columns
<REFSECT1 ID="R1-SQL-UPDATE-1"> to be modified need appear as column.
<REFSECT1INFO> </para>
<DATE>1998-09-24</DATE>
</REFSECT1INFO> <para>
<TITLE> Array references use the same syntax found in SELECT.
Description That is, either single array elements, a range of array
</TITLE> elements or the entire array may be replaced with a single
<PARA> query.
UPDATE changes the values of the columns specified for </para>
all rows which satisfy condition. Only the columns
to be modified need appear as column. <para>
</para> You must have write access to the table in order to modify
<PARA> it, as well as read access to any table whose values are
Array references use the same syntax found in SELECT. mentioned in the WHERE condition.
That is, either single array elements, a range of array </para>
elements or the entire array may be replaced with a single </refsect1>
query.
</para> <refsect1 id="R1-SQL-UPDATE-2">
<PARA> <title>
You must have write access to the table in order to modify Usage
it, as well as read access to any table whose values are </title>
mentioned in the WHERE condition.
</para> <para>
</REFSECT1> Change word "Drama" with "Dramatic" on column kind:
<REFSECT1 ID="R1-SQL-UPDATE-2"> <programlisting>
<TITLE> UPDATE films
Usage SET kind = 'Dramatic'
</TITLE> WHERE kind = 'Drama';
<PARA> SELECT * FROM films WHERE kind = 'Dramatic' OR kind = 'Drama';
</PARA>
<ProgramListing>
--Change word "Drama" with "Dramatic" on column kind:
--
UPDATE films
SET kind = 'Dramatic'
WHERE kind = 'Drama';
SELECT * FROM films WHERE kind = 'Dramatic' OR kind = 'Drama';
code |title |did| date_prod|kind |len code |title |did| date_prod|kind |len
-----+-------------+---+----------+----------+------ -----+-------------+---+----------+----------+------
...@@ -166,35 +157,52 @@ UPDATE <REPLACEABLE CLASS="PARAMETER">table</replaceable> SET <REPLACEABLE CLASS ...@@ -166,35 +157,52 @@ UPDATE <REPLACEABLE CLASS="PARAMETER">table</replaceable> SET <REPLACEABLE CLASS
M_401|War and Peace|104|1967-02-12|Dramatic | 05:57 M_401|War and Peace|104|1967-02-12|Dramatic | 05:57
T_601|Yojimbo |106|1961-06-16|Dramatic | 01:50 T_601|Yojimbo |106|1961-06-16|Dramatic | 01:50
DA101|Das Boot |110|1981-11-11|Dramatic | 02:29 DA101|Das Boot |110|1981-11-11|Dramatic | 02:29
</ProgramListing> </programlisting>
</para>
</REFSECT1> </refsect1>
<REFSECT1 ID="R1-SQL-UPDATE-3"> <refsect1 id="R1-SQL-UPDATE-3">
<TITLE> <title>
Compatibility Compatibility
</TITLE> </title>
<PARA> <para>
</PARA> </para>
<REFSECT2 ID="R2-SQL-UPDATE-4"> <refsect2 id="R2-SQL-UPDATE-4">
<REFSECT2INFO> <refsect2info>
<DATE>1998-09-24</DATE> <date>1998-09-24</date>
</REFSECT2INFO> </refsect2info>
<TITLE> <title>
SQL92 SQL92
</TITLE> </title>
<PARA> <para>
SQL92 defines a different syntax for positioned UPDATE statement: SQL92 defines a different syntax for positioned UPDATE statement:
<programlisting> <synopsis>
UPDATE table SET column = expression [, ...] UPDATE table SET column = expression [, ...]
WHERE CURRENT OF <replaceable class="parameter">cursor</replaceable> WHERE CURRENT OF <replaceable class="parameter">cursor</replaceable>
</programlisting> </synopsis>
where <replaceable class="parameter">cursor</replaceable> where <replaceable class="parameter">cursor</replaceable>
identifies an open cursor. identifies an open cursor.
</para> </para>
</refsect2> </refsect2>
</refsect1> </refsect1>
</REFENTRY> </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-VACUUM-1"> <refentry id="SQL-VACUUM-1">
<REFMETA> <refmeta>
<REFENTRYTITLE id="vacuum"> <refentrytitle id="vacuum">
VACUUM VACUUM
</REFENTRYTITLE> </refentrytitle>
<REFMISCINFO>SQL - Language Statements</REFMISCINFO> <refmiscinfo>SQL - Language Statements</refmiscinfo>
</REFMETA> </refmeta>
<REFNAMEDIV> <refnamediv>
<REFNAME> <refname>
VACUUM VACUUM
</REFNAME> </refname>
<REFPURPOSE> <refpurpose>
Clean and analyze a <productname>Postgres</productname> database Clean and analyze a <productname>Postgres</productname> database
</REFPURPOSE> </refpurpose>
</refnamediv> </refnamediv>
<REFSYNOPSISDIV> <refsynopsisdiv>
<REFSYNOPSISDIVINFO> <refsynopsisdivinfo>
<DATE>1998-10-04</DATE> <date>1998-10-04</date>
</REFSYNOPSISDIVINFO> </refsynopsisdivinfo>
<SYNOPSIS> <synopsis>
VACUUM [ VERBOSE ] [ ANALYZE ] [ <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> ] VACUUM [ VERBOSE ] [ ANALYZE ] [ <replaceable class="PARAMETER">table</replaceable> ]
VACUUM [ VERBOSE ] ANALYZE [ <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> [ (<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE> [, ...] ) ] ] VACUUM [ VERBOSE ] ANALYZE [ <replaceable class="PARAMETER">ER">t</replaceable>BLE> [ (<replaceable class="PARAMETER">column</replaceable> [, ...] ) ] ]
</SYNOPSIS> </synopsis>
<refsect2 id="R2-SQL-VACUUM-1">
<refsect2info>
<date>1998-10-04</date>
</refsect2info>
<title>
Inputs
</title>
<para>
<variablelist>
<varlistentry>
<term>VERBOSE</term>
<listitem>
<para>
Prints a detailed vacuum activity report for each table.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>ANALYZE</term>
<listitem>
<para>
Updates column statistics used by the optimizer to
determine the most efficient way to execute a query.
The statistics represent the disbursion of the data in each column.
This information is valuable when several execution paths are possible.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">table</replaceable></term>
<listitem>
<para>
The name of a specific table to vacuum. Defaults to all tables.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="PARAMETER">column</replaceable></term>
<listitem>
<para>
The name of a specific column to analyze. Defaults to all columns.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2 id="R2-SQL-VACUUM-2">
<refsect2info>
<date>1998-10-04</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<variablelist>
<varlistentry>
<term><computeroutput>
<returnvalue>VACUUM</returnvalue>
</computeroutput></term>
<listitem>
<para>
The command has been accepted and the database is being cleaned.
</para>
</listitem>
</varlistentry>
<REFSECT2 ID="R2-SQL-VACUUM-1"> <varlistentry>
<REFSECT2INFO> <term><computeroutput>
<DATE>1998-10-04</DATE> NOTICE: --Relation <replaceable class="PARAMETER">table</replaceable>--
</REFSECT2INFO> </computeroutput></term>
<TITLE> <listitem>
Inputs <para>
</TITLE> The report header for <replaceable class="PARAMETER">table</replaceable>.
<PARA> </para>
</listitem>
<VARIABLELIST> </varlistentry>
<VARLISTENTRY>
<TERM>
VERBOSE
</term>
<LISTITEM>
<PARA>
Prints a detailed vacuum activity report for each table.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
ANALYZE
</term>
<LISTITEM>
<PARA>
Updates column statistics used by the optimizer to
determine the most efficient way to execute a query.
The statistics represent the disbursion of the data in each column.
This information is valuable when several execution paths are possible.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>
</term>
<LISTITEM>
<PARA>
The name of a specific table to vacuum. Defaults to all tables.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
<REPLACEABLE CLASS="PARAMETER">column</REPLACEABLE>
</term>
<LISTITEM>
<PARA>
The name of a specific column to analyze. Defaults to all columns.
</para>
</listitem>
</varlistentry>
</VARIABLELIST>
</para>
</REFSECT2>
<REFSECT2 ID="R2-SQL-VACUUM-2"> <varlistentry>
<REFSECT2INFO> <term><computeroutput>
<DATE>1998-10-04</DATE> NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
</REFSECT2INFO> Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
<TITLE> Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
Outputs Elapsed 0/0 sec.
</TITLE> </computeroutput></term>
<PARA> <listitem>
<para>
The analysis for <replaceable class="PARAMETER">table</replaceable> itself.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><computeroutput>
NOTICE: Index <replaceable class="PARAMETER">index</replaceable>: Pages 28;
Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
</computeroutput></term>
<listitem>
<para>
The analysis for an index on the target table.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<VARIABLELIST> <refsect1 id="R1-SQL-VACUUM-1">
<VARLISTENTRY> <refsect1info>
<TERM> <date>1998-10-04</date>
<ReturnValue>VACUUM</ReturnValue> </refsect1info>
</TERM> <title>
<LISTITEM> Description
<PARA> </title>
The command has been accepted and the database is being cleaned. <para>
</para> <command>VACUUM</command> serves two purposes in
</listitem> <productname>Postgres</productname> as both a means to reclaim storage and
</varlistentry> also a means to collect information for the optimizer.
</para>
<VARLISTENTRY>
<TERM>
NOTICE: --Relation <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>--
</term>
<LISTITEM>
<PARA>
The report header for <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE>.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY> <para>
<TERM> <command>VACUUM</command> opens every class in the database,
NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0; cleans out records from rolled back transactions, and updates statistics in the
Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188; system catalogs. The statistics maintained include the number of
Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74. tuples and number of pages stored in all classes.
Elapsed 0/0 sec. </para>
</term>
<LISTITEM>
<PARA>
The analysis for <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> itself.
</para>
</listitem>
</varlistentry>
<VARLISTENTRY>
<TERM>
NOTICE: Index <REPLACEABLE CLASS="PARAMETER">index</REPLACEABLE>: Pages 28;
Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
</term>
<LISTITEM>
<PARA>
The analysis for an index on the target table.
</para>
</listitem>
</varlistentry>
</VARIABLELIST>
</para>
</REFSECT2>
</REFSYNOPSISDIV>
<REFSECT1 ID="R1-SQL-VACUUM-1"> <para>
<REFSECT1INFO> Running <command>VACUUM</command>
<DATE>1998-10-04</DATE> periodically will increase the speed of the database in processing user queries.
</REFSECT1INFO> </para>
<TITLE>
Description
</TITLE>
<PARA>
<command>VACUUM</command> serves two purposes in
<productname>Postgres</productname> as both a means to reclaim storage and
also a means to collect information for the optimizer.
</para>
<para>
<command>VACUUM</command> opens every class in the database,
cleans out records from rolled back transactions, and updates statistics in the
system catalogs. The statistics maintained include the number of
tuples and number of pages stored in all classes.
Running <command>VACUUM</command> <refsect2 id="R2-SQL-VACUUM-3">
periodically will increase the speed of the database in processing user queries. <refsect2info>
</para> <date>1998-10-04</date>
</refsect2info>
<title>
Notes
</title>
<para>
The open database is the target for <command>VACUUM</command>.
</para>
<para>
We recommend that active production databases be cleaned nightly, in order
to keep statistics relatively current. The <command>VACUUM</command>
query may be executed at any time, however. In particular, after
copying a large class into <productname>Postgres</productname>
or after deleting a large number of
records, it may be a good idea to issue a <command>VACUUM</command>
query. This will update the system catalogs with the results of all
recent changes, and allow the <productname>Postgres</productname>
query optimizer to make better choices in planning user queries.
</para>
<para>
If the server crashes during a <command>VACUUM</command> command,
chances are it will leave a lock file hanging around.
Attempts to re-run the <command>VACUUM</command> command
result in an error message about the creation of a lock file. If you
are sure <command>VACUUM</command> is not running,
remove the <filename>pg_vlock</filename> file in your
database directory
(i.e. <filename><envar>PGDATA</envar>/base/dbname/pg_vlock</filename>).
</para>
</refsect2>
</refsect1>
<REFSECT2 ID="R2-SQL-VACUUM-3"> <refsect1 id="R1-SQL-VACUUM-2">
<REFSECT2INFO> <title>
<DATE>1998-10-04</DATE> Usage
</REFSECT2INFO> </title>
<TITLE> <para>
Notes The following is an example from running <command>VACUUM</command> on a table
</TITLE> in the regression database:
<PARA>
The open database is target for <command>VACUUM</command>.
</para>
<para>
We recommend that active production databases be cleaned nightly, in order
to keep statistics relatively current. The <command>VACUUM</command>
query may be executed at any time, however. In particular, after
copying a large class into <productname>Postgres</productname>
or after deleting a large number of
records, it may be a good idea to issue a <command>VACUUM</command>
query. This will update the system catalogs with the results of all
recent changes, and allow the <productname>Postgres</productname>
query optimizer to make better choices in planning user queries.
</para>
<para>
If the server crashes during a <command>VACUUM</command> command,
chances are it will leave a lock file hanging around.
Attempts to re-run the <command>VACUUM</command> command
result in an error message about the creation of a lock file. If you
are sure <command>VACUUM</command> is not running,
remove the <filename>pg_vlock</filename> file in your
database directory
(i.e. <filename><envar>PGDATA</envar>/base/dbname/pg_vlock</filename>).
</PARA>
</REFSECT2>
</refsect1>
<REFSECT1 ID="R1-SQL-VACUUM-2"> <programlisting>
<TITLE>
Usage
</TITLE>
<PARA>
The following is an example from running <command>VACUUM</command> on a table
in the regression database:
<ProgramListing>
regression=> vacuum verbose analyze onek; regression=> vacuum verbose analyze onek;
NOTICE: --Relation onek-- NOTICE: --Relation onek--
NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0; NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
...@@ -223,24 +217,41 @@ NOTICE: Index onek_hundred: Pages 12; Tuples 1000: Deleted 1000. Elapsed 0/0 se ...@@ -223,24 +217,41 @@ NOTICE: Index onek_hundred: Pages 12; Tuples 1000: Deleted 1000. Elapsed 0/0 se
NOTICE: Index onek_unique2: Pages 19; Tuples 1000: Deleted 1000. Elapsed 0/0 sec. NOTICE: Index onek_unique2: Pages 19; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
NOTICE: Index onek_unique1: Pages 17; Tuples 1000: Deleted 1000. Elapsed 0/0 sec. NOTICE: Index onek_unique1: Pages 17; Tuples 1000: Deleted 1000. Elapsed 0/0 sec.
VACUUM VACUUM
</ProgramListing> </programlisting>
</para> </para>
</REFSECT1> </refsect1>
<refsect1 id="R1-SQL-VACUUM-3">
<title>
Compatibility
</title>
<refsect2 id="R2-SQL-VACUUM-4">
<refsect2info>
<date>1998-10-04</date>
</refsect2info>
<title>
SQL92
</title>
<para>
There is no <command>VACUUM</command> statement in SQL92.
</para>
</refsect2>
</refsect1>
</refentry>
<REFSECT1 ID="R1-SQL-VACUUM-3"> <!-- Keep this comment at the end of the file
<TITLE> Local variables:
Compatibility mode: sgml
</TITLE> sgml-omittag:nil
<REFSECT2 ID="R2-SQL-VACUUM-4"> sgml-shorttag:t
<REFSECT2INFO> sgml-minimize-attributes:nil
<DATE>1998-10-04</DATE> sgml-always-quote-attributes:t
</REFSECT2INFO> sgml-indent-step:1
<TITLE> sgml-indent-data:t
SQL92 sgml-parent-document:nil
</TITLE> sgml-default-dtd-file:"../reference.ced"
<PARA> sgml-exposed-tags:nil
There is no <COMMAND>VACUUM</COMMAND> statement in SQL92. sgml-local-catalogs:"/usr/lib/sgml/catalog"
</para> sgml-local-ecat-files:nil
</refsect2> End:
</refsect1> -->
</REFENTRY>
...@@ -18,12 +18,9 @@ ...@@ -18,12 +18,9 @@
<date>1998-10-04</date> <date>1998-10-04</date>
</refsynopsisdivinfo> </refsynopsisdivinfo>
<synopsis> <synopsis>
vacuumdb [ --analyze | -z ] [ --verbose | -v ] [ <replaceable vacuumdb [ --analyze | -z ] [ --verbose | -v ] [ <replaceable class="parameter">dbname</replaceable> ]
class="parameter">dbname</replaceable> ] vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p [ --table '<replaceable class="parameter">table</replaceable> [ ( <replaceable class="parameter">column</replaceable> [,...] ) ]' ]
<replaceable class="parameter">port</replaceable> ]
[ --table '<replaceable class="parameter">table</replaceable> [ (
<replaceable class="parameter">column</replaceable> [,...] ) ]' ]
[ <replaceable class="parameter">dbname</replaceable> ] [ <replaceable class="parameter">dbname</replaceable> ]
</synopsis> </synopsis>
...@@ -39,9 +36,7 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -39,9 +36,7 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term><replaceable class="parameter">dbname</replaceable></term>
<replaceable class="parameter">dbname</replaceable>
</term>
<listitem> <listitem>
<para> <para>
Specifies the name of the database to be cleaned or analyzed. Specifies the name of the database to be cleaned or analyzed.
...@@ -52,44 +47,30 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -52,44 +47,30 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>--analyze</term>
--analyze <term>-z</term>
</term>
<term>
-z
</term>
<listitem> <listitem>
<para> <para>
Calculate statistics on the database for use by the optimizer. Calculate statistics on the database for use by the optimizer.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>--verbose</term>
--verbose <term>-v</term>
</term>
<term>
-v
</term>
<listitem> <listitem>
<para> <para>
Print detailed information during processing. Print detailed information during processing.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>--table <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</term>
--table <replaceable class="parameter">table</replaceable> [ <term>-t <replaceable class="parameter">table</replaceable> [ (<replaceable class="parameter">column</replaceable> [,...]) ]</term>
(<replaceable class="parameter">column</replaceable> [,...]) ]
</term>
<term>
-t <replaceable class="parameter">table</replaceable> [
(<replaceable class="parameter">column</replaceable> [,...]) ]
</term>
<listitem> <listitem>
<para> <para>
Clean or analyze <replaceable class="parameter">table</replaceable> only. Clean or analyze <replaceable class="parameter">table</replaceable> only.
...@@ -98,18 +79,17 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -98,18 +79,17 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para> </para>
<para> <para>
<application>vacuumdb</application> also accepts <application>vacuumdb</application> also accepts
the following command line arguments for connection parameters: the following command line arguments for connection parameters:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>-h <replaceable class="parameter">host</replaceable></term>
-h <replaceable class="parameter">host</replaceable>
</term>
<listitem> <listitem>
<para> <para>
Specifies the hostname of the machine on which the Specifies the hostname of the machine on which the
...@@ -119,11 +99,9 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -119,11 +99,9 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>-p <replaceable class="parameter">port</replaceable></term>
-p <replaceable class="parameter">port</replaceable>
</term>
<listitem> <listitem>
<para> <para>
Specifies the Internet TCP/IP port or local Unix domain socket file Specifies the Internet TCP/IP port or local Unix domain socket file
...@@ -134,11 +112,9 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -134,11 +112,9 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term>-u</term>
-u
</term>
<listitem> <listitem>
<para> <para>
Use password authentication. Use password authentication.
...@@ -148,7 +124,6 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -148,7 +124,6 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para> </para>
</refsect2> </refsect2>
...@@ -166,11 +141,10 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -166,11 +141,10 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term><computeroutput>
ERROR: Can't vacuum columns, only tables. You can 'vacuum analyze' columns. ERROR: Can't vacuum columns, only tables. You can 'vacuum analyze' columns.
vacuumdb: database vacuum failed on <replaceable vacuumdb: database vacuum failed on <replaceable class="parameter">dbname</replaceable>.
class="parameter">dbname</replaceable>. </computeroutput></term>
</term>
<listitem> <listitem>
<para> <para>
The non-analyze mode requires cleaning full tables or databases. The non-analyze mode requires cleaning full tables or databases.
...@@ -180,11 +154,11 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -180,11 +154,11 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><computeroutput>
Connection to database 'template1' failed. Connection to database 'template1' failed.
connectDB() failed: Is the postmaster running and accepting connections connectDB() failed: Is the postmaster running and accepting connections
at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'? at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
</term> </computeroutput></term>
<listitem> <listitem>
<para> <para>
<application>vacuumdb</application> could not attach to the <application>vacuumdb</application> could not attach to the
...@@ -199,10 +173,10 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -199,10 +173,10 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term> <term><computeroutput>
Connection to database '<replaceable class="parameter">dbname</replaceable>' failed. Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow' FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
</term> </computeroutput></term>
<listitem> <listitem>
<para> <para>
You do not have a valid entry in the relation <literal>pg_shadow</literal> You do not have a valid entry in the relation <literal>pg_shadow</literal>
...@@ -211,7 +185,6 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -211,7 +185,6 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para> </para>
...@@ -234,7 +207,7 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -234,7 +207,7 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
<title> <title>
Description Description
</title> </title>
<para> <para>
<application>vacuumdb</application> is a utility for cleaning a <application>vacuumdb</application> is a utility for cleaning a
<productname>Postgres</productname> database. <productname>Postgres</productname> database.
...@@ -250,7 +223,7 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -250,7 +223,7 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
<title> <title>
Notes Notes
</title> </title>
<para> <para>
See <xref endterm="vacuum" linkend="vacuum"> for more details. See <xref endterm="vacuum" linkend="vacuum"> for more details.
</para> </para>
...@@ -267,22 +240,23 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p ...@@ -267,22 +240,23 @@ vacuumdb [ -h <replaceable class="parameter">host</replaceable> ] [ -p
To clean a database of the same name as the user: To clean a database of the same name as the user:
<programlisting> <programlisting>
% vacuumdb % vacuumdb
</programlisting> </programlisting>
</para> </para>
<para> <para>
To analyze a database named <literal>bigdb</literal> for the optimizer: To analyze a database named <literal>bigdb</literal> for the optimizer:
<programlisting> <programlisting>
% vacuumdb --analyze bigdb % vacuumdb --analyze bigdb
</programlisting> </programlisting>
</para> </para>
<para> <para>
To analyze a single column <literal>bar</literal> in table <literal>foo</literal> To analyze a single column <literal>bar</literal> in table <literal>foo</literal>
in a database named <literal>xyzzy</literal> for the optimizer: in a database named <literal>xyzzy</literal> for the optimizer:
<programlisting> <programlisting>
% vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy % vacuumdb --analyze --verbose --table 'foo(bar)' xyzzy
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>
......
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