mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Complete first pass at markup adjustments for docbook2man man pages.
Add some internal cross references to select.sgml.
This commit is contained in:
@ -1,13 +1,13 @@
|
|||||||
<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
|
|||||||
<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>] ]
|
|||||||
<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>] ]
|
|||||||
</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>] ]
|
|||||||
</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>] ]
|
|||||||
</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>] ]
|
|||||||
</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>] ]
|
|||||||
</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>] ]
|
|||||||
</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>] ]
|
|||||||
</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>] ]
|
|||||||
</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>] ]
|
|||||||
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>] ]
|
|||||||
<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> ... ]
|
|||||||
<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> ... ]
|
|||||||
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>
|
|||||||
</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>
|
|||||||
<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 ] [, .
|
|||||||
|
|
||||||
<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;
|
|||||||
</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
|
|||||||
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;
|
|||||||
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
|
|||||||
----------+------
|
----------+------
|
||||||
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;
|
|||||||
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;
|
|||||||
<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.
|
|||||||
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';
|
|||||||
<!-- 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
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
<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
|
|||||||
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.
|
|||||||
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.
|
|||||||
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.
|
|||||||
<!-- 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
|
|||||||
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 @@
|
|||||||
<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>
|
|||||||
<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>
|
|||||||
<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>
|
|||||||
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
|
|||||||
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:
|
||||||
-->
|
-->
|
||||||
|
@ -1,178 +1,197 @@
|
|||||||
<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>
|
|
||||||
<VARIABLELIST>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
Name of previously registered notify condition.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
<literal>*</literal>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
All current listen registrations for this backend are cleared.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</VARIABLELIST>
|
<para>
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable class="PARAMETER">notifyname</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Name of previously registered notify condition.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><literal>*</literal></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
All current listen registrations for this backend are cleared.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</para>
|
||||||
|
</refsect2>
|
||||||
|
|
||||||
</REFSECT2>
|
<refsect2 id="R2-SQL-UNLISTEN-2">
|
||||||
|
<refsect2info>
|
||||||
|
<date>1998-10-19</date>
|
||||||
|
</refsect2info>
|
||||||
|
<title>
|
||||||
|
Outputs
|
||||||
|
</title>
|
||||||
|
<para>
|
||||||
|
|
||||||
<REFSECT2 ID="R2-SQL-UNLISTEN-2">
|
<variablelist>
|
||||||
<REFSECT2INFO>
|
<varlistentry>
|
||||||
<DATE>1998-10-19</DATE>
|
<term><computeroutput>
|
||||||
</REFSECT2INFO>
|
|
||||||
<TITLE>
|
|
||||||
Outputs
|
|
||||||
</TITLE>
|
|
||||||
<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>
|
||||||
|
</para>
|
||||||
|
</refsect2>
|
||||||
|
</refsynopsisdiv>
|
||||||
|
|
||||||
</VARIABLELIST>
|
<refsect1 id="R1-SQL-UNLISTEN-1">
|
||||||
</para>
|
<refsect1info>
|
||||||
</REFSECT2>
|
<date>1998-10-19</date>
|
||||||
</REFSYNOPSISDIV>
|
</refsect1info>
|
||||||
|
<title>
|
||||||
|
Description
|
||||||
|
</title>
|
||||||
|
|
||||||
<REFSECT1 ID="R1-SQL-UNLISTEN-1">
|
<para>
|
||||||
<REFSECT1INFO>
|
<command>UNLISTEN</command>
|
||||||
<DATE>1998-10-19</DATE>
|
is used to remove an existing <command>NOTIFY</command> registration.
|
||||||
</REFSECT1INFO>
|
UNLISTEN cancels any existing registration of the current
|
||||||
<TITLE>
|
<productname>Postgres</productname> session as a listener on the notify
|
||||||
Description
|
condition <replaceable class="PARAMETER">notifyname</replaceable>.
|
||||||
</TITLE>
|
The special condition wildcard "*" cancels all listener registrations
|
||||||
<PARA>
|
for the current session.
|
||||||
<command>UNLISTEN</command>
|
</para>
|
||||||
is used to remove an existing <command>NOTIFY</command> registration.
|
|
||||||
UNLISTEN cancels any existing registration of the current
|
|
||||||
<productname>Postgres</productname> session as a listener on the notify
|
|
||||||
condition <REPLACEABLE CLASS="PARAMETER">notifyname</REPLACEABLE>.
|
|
||||||
The special condition wildcard "*" cancels all listener registrations
|
|
||||||
for the current session.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
<xref linkend="sql-notify" endterm="sql-notify-ref">
|
|
||||||
contains a more extensive
|
|
||||||
discussion of the use of <command>LISTEN</command> and
|
|
||||||
<command>NOTIFY</command>.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<REFSECT2 ID="R2-SQL-UNLISTEN-3">
|
<para>
|
||||||
<REFSECT2INFO>
|
<xref endterm="sql-notify-ref" linkend="sql-notify">
|
||||||
<DATE>1998-10-19</DATE>
|
contains a more extensive
|
||||||
</REFSECT2INFO>
|
discussion of the use of <command>LISTEN</command> and
|
||||||
<TITLE>
|
<command>NOTIFY</command>.
|
||||||
Notes
|
</para>
|
||||||
</TITLE>
|
|
||||||
<para>
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE>
|
|
||||||
needs not to be a valid class name but can be any string valid
|
|
||||||
as a name up to 32 characters long.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
The backend does not complain if you UNLISTEN something you were not
|
|
||||||
listening for.
|
|
||||||
Each backend will automatically execute <command>UNLISTEN *</command> when
|
|
||||||
exiting.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
A restriction in some previous releases of
|
|
||||||
<productname>Postgres</productname> that a
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">classname</REPLACEABLE>
|
|
||||||
which does not correspond to an actual table must be enclosed in double-quotes
|
|
||||||
is no longer present.
|
|
||||||
</para>
|
|
||||||
</REFSECT2>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<REFSECT1 ID="R1-SQL-UNLISTEN-2">
|
<refsect2 id="R2-SQL-UNLISTEN-3">
|
||||||
<TITLE>
|
<refsect2info>
|
||||||
Usage
|
<date>1998-10-19</date>
|
||||||
</TITLE>
|
</refsect2info>
|
||||||
|
<title>
|
||||||
|
Notes
|
||||||
|
</title>
|
||||||
|
<para>
|
||||||
|
<replaceable class="PARAMETER">classname</replaceable>
|
||||||
|
needs not to be a valid class name but can be any string valid
|
||||||
|
as a name up to 32 characters long.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
The backend does not complain if you UNLISTEN something you were not
|
||||||
|
listening for.
|
||||||
|
Each backend will automatically execute <command>UNLISTEN *</command> when
|
||||||
|
exiting.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
A restriction in some previous releases of
|
||||||
|
<productname>Postgres</productname> that a
|
||||||
|
<replaceable class="PARAMETER">classname</replaceable>
|
||||||
|
which does not correspond to an actual table must be enclosed in double-quotes
|
||||||
|
is no longer present.
|
||||||
|
</para>
|
||||||
|
</refsect2>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<para>
|
<refsect1 id="R1-SQL-UNLISTEN-2">
|
||||||
<programlisting>
|
<title>
|
||||||
|
Usage
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<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:
|
||||||
|
-->
|
||||||
|
@ -1,163 +1,154 @@
|
|||||||
<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>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">table</replaceable>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
The name of an existing table.
|
|
||||||
</para>
|
|
||||||
</LISTITEM>
|
|
||||||
</VARLISTENTRY>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">column</replaceable>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
The name of a column in <REPLACEABLE CLASS="PARAMETER">table</replaceable>.
|
|
||||||
</para>
|
|
||||||
</LISTITEM>
|
|
||||||
</VARLISTENTRY>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">expression</replaceable>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
A valid expression or value to assign to column.
|
|
||||||
</para>
|
|
||||||
</LISTITEM>
|
|
||||||
</VARLISTENTRY>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">fromlist</REPLACEABLE>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
A <productname>Postgres</productname>
|
|
||||||
non-standard extension to allow columns
|
|
||||||
from other tables to appear in the WHERE condition.
|
|
||||||
</para>
|
|
||||||
</LISTITEM>
|
|
||||||
</VARLISTENTRY>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
<REPLACEABLE CLASS="PARAMETER">condition</REPLACEABLE>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
Refer to the SELECT statement for a further description
|
|
||||||
of the WHERE clause.
|
|
||||||
</para>
|
|
||||||
</LISTITEM>
|
|
||||||
</VARLISTENTRY>
|
|
||||||
</VARIABLELIST>
|
|
||||||
</para>
|
|
||||||
</REFSECT2>
|
|
||||||
|
|
||||||
<REFSECT2 ID="R2-SQL-UPDATE-2">
|
|
||||||
<REFSECT2INFO>
|
|
||||||
<DATE>1998-09-24</DATE>
|
|
||||||
</REFSECT2INFO>
|
|
||||||
<TITLE>
|
|
||||||
Outputs
|
|
||||||
</TITLE>
|
|
||||||
<PARA>
|
|
||||||
|
|
||||||
<VARIABLELIST>
|
|
||||||
<VARLISTENTRY>
|
|
||||||
<TERM>
|
|
||||||
UPDATE <replaceable class="parameter">#</replaceable>
|
|
||||||
</TERM>
|
|
||||||
<LISTITEM>
|
|
||||||
<PARA>
|
|
||||||
Message returned if successful.
|
|
||||||
The <replaceable class="parameter">#</replaceable>
|
|
||||||
means the number of rows updated.
|
|
||||||
If <replaceable class="parameter">#</replaceable>
|
|
||||||
is equal 0 no rows are updated.
|
|
||||||
</para>
|
|
||||||
</LISTITEM>
|
|
||||||
</VARLISTENTRY>
|
|
||||||
</VARIABLELIST>
|
|
||||||
</para>
|
|
||||||
</REFSECT2>
|
|
||||||
</REFSYNOPSISDIV>
|
|
||||||
|
|
||||||
<REFSECT1 ID="R1-SQL-UPDATE-1">
|
<variablelist>
|
||||||
<REFSECT1INFO>
|
<varlistentry>
|
||||||
<DATE>1998-09-24</DATE>
|
<term><replaceable class="PARAMETER">table</replaceable></term>
|
||||||
</REFSECT1INFO>
|
<listitem>
|
||||||
<TITLE>
|
<para>
|
||||||
Description
|
The name of an existing table.
|
||||||
</TITLE>
|
</para>
|
||||||
<PARA>
|
</listitem>
|
||||||
UPDATE changes the values of the columns specified for
|
</varlistentry>
|
||||||
all rows which satisfy condition. Only the columns
|
<varlistentry>
|
||||||
to be modified need appear as column.
|
<term><replaceable class="PARAMETER">column</replaceable></term>
|
||||||
</para>
|
<listitem>
|
||||||
<PARA>
|
<para>
|
||||||
Array references use the same syntax found in SELECT.
|
The name of a column in <replaceable class="PARAMETER">table</replaceable>.
|
||||||
That is, either single array elements, a range of array
|
</para>
|
||||||
elements or the entire array may be replaced with a single
|
</listitem>
|
||||||
query.
|
</varlistentry>
|
||||||
</para>
|
<varlistentry>
|
||||||
<PARA>
|
<term><replaceable class="PARAMETER">expression</replaceable></term>
|
||||||
You must have write access to the table in order to modify
|
<listitem>
|
||||||
it, as well as read access to any table whose values are
|
<para>
|
||||||
mentioned in the WHERE condition.
|
A valid expression or value to assign to column.
|
||||||
</para>
|
</para>
|
||||||
</REFSECT1>
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable class="PARAMETER">fromlist</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
A <productname>Postgres</productname>
|
||||||
|
non-standard extension to allow columns
|
||||||
|
from other tables to appear in the WHERE condition.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
<varlistentry>
|
||||||
|
<term><replaceable class="PARAMETER">condition</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Refer to the SELECT statement for a further description
|
||||||
|
of the WHERE clause.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</para>
|
||||||
|
</refsect2>
|
||||||
|
|
||||||
<REFSECT1 ID="R1-SQL-UPDATE-2">
|
<refsect2 id="R2-SQL-UPDATE-2">
|
||||||
<TITLE>
|
<refsect2info>
|
||||||
Usage
|
<date>1998-09-24</date>
|
||||||
</TITLE>
|
</refsect2info>
|
||||||
<PARA>
|
<title>
|
||||||
</PARA>
|
Outputs
|
||||||
<ProgramListing>
|
</title>
|
||||||
--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';
|
<para>
|
||||||
|
<variablelist>
|
||||||
|
<varlistentry>
|
||||||
|
<term><computeroutput>
|
||||||
|
UPDATE <replaceable class="parameter">#</replaceable>
|
||||||
|
</computeroutput></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Message returned if successful.
|
||||||
|
The <replaceable class="parameter">#</replaceable>
|
||||||
|
means the number of rows updated.
|
||||||
|
If <replaceable class="parameter">#</replaceable>
|
||||||
|
is equal 0 no rows are updated.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
</variablelist>
|
||||||
|
</para>
|
||||||
|
</refsect2>
|
||||||
|
</refsynopsisdiv>
|
||||||
|
|
||||||
|
<refsect1 id="R1-SQL-UPDATE-1">
|
||||||
|
<refsect1info>
|
||||||
|
<date>1998-09-24</date>
|
||||||
|
</refsect1info>
|
||||||
|
<title>
|
||||||
|
Description
|
||||||
|
</title>
|
||||||
|
<para>
|
||||||
|
<command>UPDATE</command> changes the values of the columns specified for
|
||||||
|
all rows which satisfy condition. Only the columns
|
||||||
|
to be modified need appear as column.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Array references use the same syntax found in SELECT.
|
||||||
|
That is, either single array elements, a range of array
|
||||||
|
elements or the entire array may be replaced with a single
|
||||||
|
query.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You must have write access to the table in order to modify
|
||||||
|
it, as well as read access to any table whose values are
|
||||||
|
mentioned in the WHERE condition.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1 id="R1-SQL-UPDATE-2">
|
||||||
|
<title>
|
||||||
|
Usage
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Change word "Drama" with "Dramatic" on column kind:
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
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
|
|||||||
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">
|
||||||
|
<title>
|
||||||
|
Compatibility
|
||||||
|
</title>
|
||||||
|
<para>
|
||||||
|
</para>
|
||||||
|
|
||||||
<REFSECT1 ID="R1-SQL-UPDATE-3">
|
<refsect2 id="R2-SQL-UPDATE-4">
|
||||||
<TITLE>
|
<refsect2info>
|
||||||
Compatibility
|
<date>1998-09-24</date>
|
||||||
</TITLE>
|
</refsect2info>
|
||||||
<PARA>
|
<title>
|
||||||
</PARA>
|
SQL92
|
||||||
|
</title>
|
||||||
<REFSECT2 ID="R2-SQL-UPDATE-4">
|
<para>
|
||||||
<REFSECT2INFO>
|
SQL92 defines a different syntax for positioned UPDATE statement:
|
||||||
<DATE>1998-09-24</DATE>
|
|
||||||
</REFSECT2INFO>
|
|
||||||
<TITLE>
|
|
||||||
SQL92
|
|
||||||
</TITLE>
|
|
||||||
<PARA>
|
|
||||||
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:
|
||||||
|
-->
|
||||||
|
@ -1,212 +1,206 @@
|
|||||||
<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">
|
<refsect2 id="R2-SQL-VACUUM-1">
|
||||||
<REFSECT2INFO>
|
<refsect2info>
|
||||||
<DATE>1998-10-04</DATE>
|
<date>1998-10-04</date>
|
||||||
</REFSECT2INFO>
|
</refsect2info>
|
||||||
<TITLE>
|
<title>
|
||||||
Inputs
|
Inputs
|
||||||
</TITLE>
|
</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">
|
<para>
|
||||||
<REFSECT2INFO>
|
<variablelist>
|
||||||
<DATE>1998-10-04</DATE>
|
<varlistentry>
|
||||||
</REFSECT2INFO>
|
<term>VERBOSE</term>
|
||||||
<TITLE>
|
<listitem>
|
||||||
Outputs
|
<para>
|
||||||
</TITLE>
|
Prints a detailed vacuum activity report for each table.
|
||||||
<PARA>
|
</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>
|
||||||
|
|
||||||
<VARIABLELIST>
|
<refsect2 id="R2-SQL-VACUUM-2">
|
||||||
<VARLISTENTRY>
|
<refsect2info>
|
||||||
<TERM>
|
<date>1998-10-04</date>
|
||||||
<ReturnValue>VACUUM</ReturnValue>
|
</refsect2info>
|
||||||
</TERM>
|
<title>
|
||||||
<LISTITEM>
|
Outputs
|
||||||
<PARA>
|
</title>
|
||||||
The command has been accepted and the database is being cleaned.
|
<para>
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<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>
|
<variablelist>
|
||||||
<TERM>
|
<varlistentry>
|
||||||
NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
|
<term><computeroutput>
|
||||||
Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
|
<returnvalue>VACUUM</returnvalue>
|
||||||
Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
|
</computeroutput></term>
|
||||||
Elapsed 0/0 sec.
|
<listitem>
|
||||||
</term>
|
<para>
|
||||||
<LISTITEM>
|
The command has been accepted and the database is being cleaned.
|
||||||
<PARA>
|
</para>
|
||||||
The analysis for <REPLACEABLE CLASS="PARAMETER">table</REPLACEABLE> itself.
|
</listitem>
|
||||||
</para>
|
</varlistentry>
|
||||||
</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">
|
<varlistentry>
|
||||||
<REFSECT1INFO>
|
<term><computeroutput>
|
||||||
<DATE>1998-10-04</DATE>
|
NOTICE: --Relation <replaceable class="PARAMETER">table</replaceable>--
|
||||||
</REFSECT1INFO>
|
</computeroutput></term>
|
||||||
<TITLE>
|
<listitem>
|
||||||
Description
|
<para>
|
||||||
</TITLE>
|
The report header for <replaceable class="PARAMETER">table</replaceable>.
|
||||||
<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>
|
|
||||||
<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>
|
<varlistentry>
|
||||||
periodically will increase the speed of the database in processing user queries.
|
<term><computeroutput>
|
||||||
</para>
|
NOTICE: Pages 98: Changed 25, Reapped 74, Empty 0, New 0;
|
||||||
|
Tup 1000: Vac 3000, Crash 0, UnUsed 0, MinLen 188, MaxLen 188;
|
||||||
|
Re-using: Free/Avail. Space 586952/586952; EndEmpty/Avail. Pages 0/74.
|
||||||
|
Elapsed 0/0 sec.
|
||||||
|
</computeroutput></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The analysis for <replaceable class="PARAMETER">table</replaceable> itself.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<REFSECT2 ID="R2-SQL-VACUUM-3">
|
<varlistentry>
|
||||||
<REFSECT2INFO>
|
<term><computeroutput>
|
||||||
<DATE>1998-10-04</DATE>
|
NOTICE: Index <replaceable class="PARAMETER">index</replaceable>: Pages 28;
|
||||||
</REFSECT2INFO>
|
Tuples 1000: Deleted 3000. Elapsed 0/0 sec.
|
||||||
<TITLE>
|
</computeroutput></term>
|
||||||
Notes
|
<listitem>
|
||||||
</TITLE>
|
<para>
|
||||||
<PARA>
|
The analysis for an index on the target table.
|
||||||
The open database is target for <command>VACUUM</command>.
|
</para>
|
||||||
</para>
|
</listitem>
|
||||||
<para>
|
</varlistentry>
|
||||||
We recommend that active production databases be cleaned nightly, in order
|
</variablelist>
|
||||||
to keep statistics relatively current. The <command>VACUUM</command>
|
</para>
|
||||||
query may be executed at any time, however. In particular, after
|
</refsect2>
|
||||||
copying a large class into <productname>Postgres</productname>
|
</refsynopsisdiv>
|
||||||
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">
|
<refsect1 id="R1-SQL-VACUUM-1">
|
||||||
<TITLE>
|
<refsect1info>
|
||||||
Usage
|
<date>1998-10-04</date>
|
||||||
</TITLE>
|
</refsect1info>
|
||||||
<PARA>
|
<title>
|
||||||
The following is an example from running <command>VACUUM</command> on a table
|
Description
|
||||||
in the regression database:
|
</title>
|
||||||
|
<para>
|
||||||
<ProgramListing>
|
<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.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Running <command>VACUUM</command>
|
||||||
|
periodically will increase the speed of the database in processing user queries.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<refsect2 id="R2-SQL-VACUUM-3">
|
||||||
|
<refsect2info>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<refsect1 id="R1-SQL-VACUUM-2">
|
||||||
|
<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
|
|||||||
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">
|
<refsect1 id="R1-SQL-VACUUM-3">
|
||||||
<TITLE>
|
<title>
|
||||||
Compatibility
|
Compatibility
|
||||||
</TITLE>
|
</title>
|
||||||
<REFSECT2 ID="R2-SQL-VACUUM-4">
|
<refsect2 id="R2-SQL-VACUUM-4">
|
||||||
<REFSECT2INFO>
|
<refsect2info>
|
||||||
<DATE>1998-10-04</DATE>
|
<date>1998-10-04</date>
|
||||||
</REFSECT2INFO>
|
</refsect2info>
|
||||||
<TITLE>
|
<title>
|
||||||
SQL92
|
SQL92
|
||||||
</TITLE>
|
</title>
|
||||||
<PARA>
|
<para>
|
||||||
There is no <COMMAND>VACUUM</COMMAND> statement in SQL92.
|
There is no <command>VACUUM</command> statement in SQL92.
|
||||||
</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:
|
||||||
|
-->
|
||||||
|
@ -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
|
|||||||
|
|
||||||
<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
|
|||||||
</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
|
|||||||
</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
|
|||||||
</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
|
|||||||
</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
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</para>
|
</para>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
@ -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
|
|||||||
</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
|
|||||||
</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
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
@ -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
|
|||||||
<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
|
|||||||
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>
|
||||||
|
Reference in New Issue
Block a user