These settings control the behavior of the <firstterm>autovacuum</firstterm>
feature. Refer to <xref linkend="autovacuum"/> for more information.
Note that many of these settings can be overridden on a per-table
- basis; see <xref linkend="sql-createtable-storage-parameters"
- endterm="sql-createtable-storage-parameters-title"/>.
+ basis; see <xref linkend="sql-createtable-storage-parameters"/>.
</para>
<variablelist>
</para></entry>
</row>
- <row id="function-encode">
+ <row>
<entry role="func_table_entry"><para role="func_signature">
- <indexterm>
+ <indexterm id="function-encode">
<primary>encode</primary>
</indexterm>
<function>encode</function> ( <parameter>bytes</parameter> <type>bytea</type>,
</para></entry>
</row>
- <row id="function-decode">
+ <row>
<entry role="func_table_entry"><para role="func_signature">
- <indexterm>
+ <indexterm id="function-decode">
<primary>decode</primary>
</indexterm>
<function>decode</function> ( <parameter>string</parameter> <type>text</type>,
In production environments this is often unacceptable.
It is possible to allow writes to occur in parallel with index
creation, but there are several caveats to be aware of —
- for more information see <xref linkend="sql-createindex-concurrently"
- endterm="sql-createindex-concurrently-title"/>.
+ for more information see <xref linkend="sql-createindex-concurrently"/>.
</para>
<para>
The default thresholds and scale factors are taken from
<filename>postgresql.conf</filename>, but it is possible to override them
(and many other autovacuum control parameters) on a per-table basis; see
- <xref linkend="sql-createtable-storage-parameters"
- endterm="sql-createtable-storage-parameters-title"/> for more information.
+ <xref linkend="sql-createtable-storage-parameters"/> for more information.
If a setting has been changed via a table's storage parameters, that value
is used when processing that table; otherwise the global settings are
used. See <xref linkend="runtime-config-autovacuum"/> for more details on
<title>The <literal>FROM</literal> Clause</title>
<para>
- The <xref linkend="sql-from" endterm="sql-from-title"/> derives a
+ The <link linkend="sql-from"><literal>FROM</literal></link> clause derives a
table from one or more other tables given in a comma-separated
table reference list.
<synopsis>
</indexterm>
<para>
- The syntax of the <xref linkend="sql-where"
- endterm="sql-where-title"/> is
+ The syntax of the <link linkend="sql-where"><literal>WHERE</literal></link>
+ clause is
<synopsis>
WHERE <replaceable>search_condition</replaceable>
</synopsis>
</synopsis>
<para>
- The <xref linkend="sql-groupby" endterm="sql-groupby-title"/> is
+ The <link linkend="sql-groupby"><literal>GROUP BY</literal></link> clause is
used to group together those rows in a table that have the same
values in all the columns listed. The order in which the columns
are listed does not matter. The effect is to combine each set
<listitem>
<para>
Update the collation's version.
- See <xref linkend="sql-altercollation-notes"
- endterm="sql-altercollation-notes-title"/> below.
+ See <xref linkend="sql-altercollation-notes"/> below.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
- <refsect1 id="sql-altercollation-notes">
- <title id="sql-altercollation-notes-title">Notes</title>
+ <refsect1 id="sql-altercollation-notes" xreflabel="Notes">
+ <title>Notes</title>
<para>
When using collations provided by the ICU library, the ICU-specific version
database will not assume that the constraint holds for all rows in
the table, until it is validated by using the <literal>VALIDATE
CONSTRAINT</literal> option.
- See <xref linkend="sql-altertable-notes"
- endterm="sql-altertable-notes-title"/> below for more information
+ See <xref linkend="sql-altertable-notes"/> below for more information
about using the <literal>NOT VALID</literal> option.
</para>
previously created as <literal>NOT VALID</literal>, by scanning the
table to ensure there are no rows for which the constraint is not
satisfied. Nothing happens if the constraint is already marked valid.
- (See <xref linkend="sql-altertable-notes"
- endterm="sql-altertable-notes-title"/> below for an explanation of the
- usefulness of this command.)
+ (See <xref linkend="sql-altertable-notes"/> below for an explanation
+ of the usefulness of this command.)
</para>
</listitem>
</varlistentry>
<listitem>
<para>
This form changes one or more storage parameters for the table. See
- <xref linkend="sql-createtable-storage-parameters"
- endterm="sql-createtable-storage-parameters-title"/>
+ <xref linkend="sql-createtable-storage-parameters"/> in the
+ <xref linkend="sql-createtable"/> documentation
for details on the available parameters. Note that the table contents
will not be modified immediately by this command; depending on the
parameter you might need to rewrite the table to get the desired effects.
</variablelist>
</refsect1>
- <refsect1 id="sql-altertable-notes">
- <title id="sql-altertable-notes-title">Notes</title>
+ <refsect1 id="sql-altertable-notes" xreflabel="Notes">
+ <title>Notes</title>
<para>
The key word <literal>COLUMN</literal> is noise and can be omitted.
This option specifies whether the final function is a pure function
that does not modify its arguments. <literal>READ_ONLY</literal> indicates
it does not; the other two values indicate that it may change the
- transition state value. See <xref linkend="sql-createaggregate-notes"
- endterm="sql-createaggregate-notes-title"/> below for more detail. The
+ transition state value. See <xref linkend="sql-createaggregate-notes"/>
+ below for more detail. The
default is <literal>READ_ONLY</literal>, except for ordered-set aggregates,
for which the default is <literal>READ_WRITE</literal>.
</para>
</para>
</refsect1>
- <refsect1 id="sql-createaggregate-notes">
- <title id="sql-createaggregate-notes-title">Notes</title>
+ <refsect1 id="sql-createaggregate-notes" xreflabel="Notes">
+ <title>Notes</title>
<para>
In parameters that specify support function names, you can write
updates, or deletes on the table; whereas a standard index build
locks out writes (but not reads) on the table until it's done.
There are several caveats to be aware of when using this option
- — see <xref linkend="sql-createindex-concurrently"
- endterm="sql-createindex-concurrently-title"/>.
+ — see <xref linkend="sql-createindex-concurrently"/> below.
</para>
<para>
For temporary tables, <command>CREATE INDEX</command> is always
<listitem>
<para>
The name of an index-method-specific storage parameter. See
- <xref linkend="sql-createindex-storage-parameters" endterm="sql-createindex-storage-parameters-title"/>
+ <xref linkend="sql-createindex-storage-parameters"/> below
for details.
</para>
</listitem>
</variablelist>
- <refsect2 id="sql-createindex-storage-parameters">
- <title id="sql-createindex-storage-parameters-title">Index Storage Parameters</title>
+ <refsect2 id="sql-createindex-storage-parameters" xreflabel="Index Storage Parameters">
+ <title>Index Storage Parameters</title>
<para>
The optional <literal>WITH</literal> clause specifies <firstterm>storage
</variablelist>
</refsect2>
- <refsect2 id="sql-createindex-concurrently">
- <title id="sql-createindex-concurrently-title">Building Indexes Concurrently</title>
+ <refsect2 id="sql-createindex-concurrently" xreflabel="Building Indexes Concurrently">
+ <title>Building Indexes Concurrently</title>
<indexterm zone="sql-createindex-concurrently">
<primary>index</primary>
</para>
<para>
- An <firstterm>operator class</firstterm> with its optional parameters
+ An <firstterm>operator class</firstterm> with optional parameters
can be specified for each column of an index.
The operator class identifies the operators to be
used by the index for that column. For example, a B-tree index on
<listitem>
<para>
This clause specifies optional storage parameters for the new
- materialized view; see <xref linkend="sql-createtable-storage-parameters"
- endterm="sql-createtable-storage-parameters-title"/> for more
+ materialized view; see
+ <xref linkend="sql-createtable-storage-parameters"/> in the
+ <xref linkend="sql-createtable"/> documentation for more
information. All parameters supported for <literal>CREATE
TABLE</literal> are also supported for <literal>CREATE MATERIALIZED
VIEW</literal>.
can be written before <literal>TEMPORARY</literal> or <literal>TEMP</literal>.
This presently makes no difference in <productname>PostgreSQL</productname>
and is deprecated; see
- <xref linkend="sql-createtable-compatibility"
- endterm="sql-createtable-compatibility-title"/>.
+ <xref linkend="sql-createtable-compatibility"/> below.
</para>
</listitem>
</varlistentry>
<listitem>
<para>
This clause specifies optional storage parameters for a table or index;
- see <xref linkend="sql-createtable-storage-parameters"
- endterm="sql-createtable-storage-parameters-title"/> for more
+ see <xref linkend="sql-createtable-storage-parameters"/> below for more
information. For backward-compatibility the <literal>WITH</literal>
clause for a table can also include <literal>OIDS=FALSE</literal> to
specify that rows of the new table should not contain OIDs (object
</variablelist>
- <refsect2 id="sql-createtable-storage-parameters">
- <title id="sql-createtable-storage-parameters-title">Storage Parameters</title>
+ <refsect2 id="sql-createtable-storage-parameters" xreflabel="Storage Parameters">
+ <title>Storage Parameters</title>
<indexterm zone="sql-createtable-storage-parameters">
<primary>storage parameters</primary>
</programlisting></para>
</refsect1>
- <refsect1 id="sql-createtable-compatibility">
- <title id="sql-createtable-compatibility-title">Compatibility</title>
+ <refsect1 id="sql-createtable-compatibility" xreflabel="Compatibility">
+ <title>Compatibility</title>
<para>
The <command>CREATE TABLE</command> command conforms to the
<listitem>
<para>
This clause specifies optional storage parameters for the new table;
- see <xref linkend="sql-createtable-storage-parameters"
- endterm="sql-createtable-storage-parameters-title"/> for more
+ see <xref linkend="sql-createtable-storage-parameters"/> in the
+ <xref linkend="sql-createtable"/> documentation for more
information. For backward-compatibility the <literal>WITH</literal>
clause for a table can also include <literal>OIDS=FALSE</literal> to
specify that rows of the new table should contain no OIDs (object
<literal>NO SCROLL</literal> specifies that the cursor cannot be
used to retrieve rows in a nonsequential fashion. The default is to
allow scrolling in some cases; this is not the same as specifying
- <literal>SCROLL</literal>. See <xref linkend="sql-declare-notes"
- endterm="sql-declare-notes-title"/> for details.
+ <literal>SCROLL</literal>. See <xref linkend="sql-declare-notes"/>
+ below for details.
</para>
</listitem>
</varlistentry>
</para>
</refsect1>
- <refsect1 id="sql-declare-notes">
- <title id="sql-declare-notes-title">Notes</title>
+ <refsect1 id="sql-declare-notes" xreflabel="Notes">
+ <title>Notes</title>
<para>
Normal cursors return data in text format, the same as a
<para>
A table expression allowing columns from other tables to appear
in the <literal>WHERE</literal> condition. This uses the same
- syntax as the <xref linkend="sql-from" endterm="sql-from-title"/>
- of a <command>SELECT</command> statement; for example, an alias
+ syntax as the <link linkend="sql-from"><literal>FROM</literal></link>
+ clause of a <command>SELECT</command> statement; for example, an alias
for the table name can be specified. Do not repeat the target
table as a <replaceable class="parameter">from_item</replaceable>
unless you wish to set up a self-join (in which case it must appear
<refsect1>
<title>Examples</title>
<para>
- Examples are given in the <xref linkend="sql-prepare-examples"
- endterm="sql-prepare-examples-title"/> section of the <xref
- linkend="sql-prepare"/> documentation.
+ Examples are given in <xref linkend="sql-prepare-examples"/>
+ in the <xref linkend="sql-prepare"/> documentation.
</para>
</refsect1>
<para>
<literal>ON CONFLICT</literal> can be used to specify an alternative
action to raising a unique constraint or exclusion constraint
- violation error. (See <xref linkend="sql-on-conflict"
- endterm="sql-on-conflict-title"/> below.)
+ violation error. (See <xref linkend="sql-on-conflict"/> below.)
</para>
<para>
<refsect1>
<title>Parameters</title>
- <refsect2 id="sql-inserting-params">
- <title id="sql-inserting-params-title">Inserting</title>
+ <refsect2>
+ <title>Inserting</title>
<para>
This section covers parameters that may be used when only
</variablelist>
</refsect2>
- <refsect2 id="sql-on-conflict">
- <title id="sql-on-conflict-title"><literal>ON CONFLICT</literal> Clause</title>
+ <refsect2 id="sql-on-conflict" xreflabel="ON CONFLICT Clause">
+ <title><literal>ON CONFLICT</literal> Clause</title>
<indexterm zone="sql-insert">
<primary>UPSERT</primary>
</indexterm>
<command>LOCK TABLE</command> is concerned, differing only in the rules
about which modes conflict with which. For information on how to
acquire an actual row-level lock, see <xref linkend="locking-rows"/>
- and the <xref linkend="sql-for-update-share"
- endterm="sql-for-update-share-title"/> in the <command>SELECT</command>
- reference documentation.
+ and <xref linkend="sql-for-update-share"/>
+ in the <xref linkend="sql-select"/> documentation.
</para>
</refsect1>
selected by writing multiple <option>-n</option> switches. The
<replaceable class="parameter">pattern</replaceable> parameter is
interpreted as a pattern according to the same rules used by
- <application>psql</application>'s <literal>\d</literal> commands (see <xref
- linkend="app-psql-patterns" endterm="app-psql-patterns-title"/>),
+ <application>psql</application>'s <literal>\d</literal> commands
+ (see <xref linkend="app-psql-patterns"/> below),
so multiple schemas can also be selected by writing wildcard characters
in the pattern. When using wildcards, be careful to quote the pattern
if needed to prevent the shell from expanding the wildcards; see
- <xref linkend="pg-dump-examples" endterm="pg-dump-examples-title"/>.
+ <xref linkend="pg-dump-examples"/> below.
</para>
<note>
can be selected by writing multiple <option>-t</option> switches. The
<replaceable class="parameter">pattern</replaceable> parameter is
interpreted as a pattern according to the same rules used by
- <application>psql</application>'s <literal>\d</literal> commands (see <xref
- linkend="app-psql-patterns" endterm="app-psql-patterns-title"/>),
+ <application>psql</application>'s <literal>\d</literal> commands
+ (see <xref linkend="app-psql-patterns"/> below),
so multiple tables can also be selected by writing wildcard characters
in the pattern. When using wildcards, be careful to quote the pattern
if needed to prevent the shell from expanding the wildcards; see
- <xref linkend="pg-dump-examples" endterm="pg-dump-examples-title"/>.
+ <xref linkend="pg-dump-examples"/> below.
</para>
<para>
<option>--include-foreign-data</option> switches.
Also, the <replaceable class="parameter">foreignserver</replaceable> parameter is
interpreted as a pattern according to the same rules used by
- <application>psql</application>'s <literal>\d</literal> commands (see <xref
- linkend="app-psql-patterns" endterm="app-psql-patterns-title"/>),
+ <application>psql</application>'s <literal>\d</literal> commands
+ (see <xref linkend="app-psql-patterns"/> below),
so multiple foreign servers can also be selected by writing wildcard characters
in the pattern. When using wildcards, be careful to quote the pattern
if needed to prevent the shell from expanding the wildcards; see
- <xref linkend="pg-dump-examples" endterm="pg-dump-examples-title"/>.
+ <xref linkend="pg-dump-examples"/> below.
The only exception is that an empty pattern is disallowed.
</para>
</para>
</refsect1>
- <refsect1 id="pg-dump-examples">
- <title id="pg-dump-examples-title">Examples</title>
+ <refsect1 id="pg-dump-examples" xreflabel="Examples">
+ <title>Examples</title>
<para>
To dump a database called <literal>mydb</literal> into a SQL-script file:
<para>
To specify an upper-case or mixed-case name in <option>-t</option> and related
switches, you need to double-quote the name; else it will be folded to
- lower case (see <xref
- linkend="app-psql-patterns" endterm="app-psql-patterns-title"/>). But
+ lower case (see <xref linkend="app-psql-patterns"/> below). But
double quotes are special to the shell, so in turn they must be quoted.
Thus, to dump a single table with a mixed-case name, you need something
like
<replaceable class="parameter">pattern</replaceable> parameter is
interpreted as a pattern according to the same rules used by
<application>psql</application>'s <literal>\d</literal>
- commands (see <xref
- linkend="app-psql-patterns" endterm="app-psql-patterns-title"/>),
+ commands (see <xref linkend="app-psql-patterns"/> below),
so multiple databases can also be excluded by writing wildcard
characters in the pattern. When using wildcards, be careful to
quote the pattern if needed to prevent shell wildcard expansion.
<para>
The following options only apply to the single-user mode
- (see <xref linkend="app-postgres-single-user"
- endterm="app-postgres-single-user-title"/>).
+ (see <xref linkend="app-postgres-single-user"/> below).
</para>
<variablelist>
</para>
</refsect1>
- <refsect1 id="app-postgres-single-user">
- <title id="app-postgres-single-user-title">Single-User Mode</title>
+ <refsect1 id="app-postgres-single-user" xreflabel="Single-User Mode">
+ <title>Single-User Mode</title>
<para>
To start a single-user mode server, use a command like
</para>
</refsect1>
- <refsect1 id="sql-prepare-examples">
- <title id="sql-prepare-examples-title">Examples</title>
+ <refsect1 id="sql-prepare-examples" xreflabel="Examples">
+ <title>Examples</title>
<para>
Create a prepared statement for an <command>INSERT</command>
statement, and then execute it:
If an unquoted colon (<literal>:</literal>) followed by a
<application>psql</application> variable name appears within an argument, it is
replaced by the variable's value, as described in <xref
- linkend="app-psql-interpolation" endterm="app-psql-interpolation-title"/>.
+ linkend="app-psql-interpolation"/> below.
The forms <literal>:'<replaceable>variable_name</replaceable>'</literal> and
<literal>:"<replaceable>variable_name</replaceable>"</literal> described there
work as well.
also shown. For foreign tables, the associated foreign
server is shown as well.
(<quote>Matching the pattern</quote> is defined in
- <xref linkend="app-psql-patterns" endterm="app-psql-patterns-title"/>
- below.)
+ <xref linkend="app-psql-patterns"/> below.)
</para>
<para>
<tip>
<para>
- See under <xref linkend="app-psql-environment"
- endterm="app-psql-environment-title"/> for how to configure and
- customize your editor.
+ See <xref linkend="app-psql-environment"/>, below, for how to
+ configure and customize your editor.
</para>
</tip>
</listitem>
<tip>
<para>
- See under <xref linkend="app-psql-environment"
- endterm="app-psql-environment-title"/> for how to configure and
- customize your editor.
+ See <xref linkend="app-psql-environment"/>, below, for how to
+ configure and customize your editor.
</para>
</tip>
</listitem>
<listitem>
<para>
Sends the current query buffer to the server and stores the
- query's output into <application>psql</application> variables (see <xref
- linkend="app-psql-variables" endterm="app-psql-variables-title"/>).
+ query's output into <application>psql</application> variables
+ (see <xref linkend="app-psql-variables"/> below).
The query to be executed must return exactly one row. Each column of
the row is stored into a separate variable, named the same as the
column. For example:
<para>
Illustrations of how these different formats look can be seen in
- the <xref linkend="app-psql-examples"
- endterm="app-psql-examples-title"/> section.
+ <xref linkend="app-psql-examples"/>, below.
</para>
<tip>
<para>
Valid variable names can contain letters, digits, and
- underscores. See the section <xref
- linkend="app-psql-variables"
- endterm="app-psql-variables-title"/> below for details.
+ underscores. See <xref linkend="app-psql-variables"/> below for details.
Variable names are case-sensitive.
</para>
Certain variables are special, in that they
control <application>psql</application>'s behavior or are
automatically set to reflect connection state. These variables are
- documented in <xref linkend="app-psql-variables"
- endterm="app-psql-variables-title"/>, below.
+ documented in <xref linkend="app-psql-variables"/>, below.
</para>
<note>
Most variables that control <application>psql</application>'s behavior
cannot be unset; instead, an <literal>\unset</literal> command is interpreted
as setting them to their default values.
- See <xref linkend="app-psql-variables"
- endterm="app-psql-variables-title"/>, below.
+ See <xref linkend="app-psql-variables"/> below.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
- <refsect3 id="app-psql-patterns">
- <title id="app-psql-patterns-title">Patterns</title>
+ <refsect3 id="app-psql-patterns" xreflabel="Patterns">
+ <title>Patterns</title>
<indexterm>
<primary>patterns</primary>
<refsect2>
<title>Advanced Features</title>
- <refsect3 id="app-psql-variables">
- <title id="app-psql-variables-title">Variables</title>
+ <refsect3 id="app-psql-variables" xreflabel="Variables">
+ <title>Variables</title>
<para>
<application>psql</application> provides variable substitution
bar
</programlisting>
This works in both regular SQL commands and meta-commands; there is
- more detail in <xref linkend="app-psql-interpolation"
- endterm="app-psql-interpolation-title"/>, below.
+ more detail in <xref linkend="app-psql-interpolation"/>, below.
</para>
<para>
<para>
These specify what the prompts <application>psql</application>
issues should look like. See <xref
- linkend="app-psql-prompting"
- endterm="app-psql-prompting-title"/> below.
+ linkend="app-psql-prompting"/> below.
</para>
</listitem>
</varlistentry>
</refsect3>
- <refsect3 id="app-psql-interpolation">
- <title id="app-psql-interpolation-title"><acronym>SQL</acronym> Interpolation</title>
+ <refsect3 id="app-psql-interpolation" xreflabel="SQL Interpolation">
+ <title><acronym>SQL</acronym> Interpolation</title>
<para>
A key feature of <application>psql</application>
</refsect3>
- <refsect3 id="app-psql-prompting">
- <title id="app-psql-prompting-title">Prompting</title>
+ <refsect3 id="app-psql-prompting" xreflabel="Prompting">
+ <title>Prompting</title>
<para>
The prompts <application>psql</application> issues can be customized
<listitem>
<para>
The value of the <application>psql</application> variable
- <replaceable class="parameter">name</replaceable>. See the
- section <xref linkend="app-psql-variables"
- endterm="app-psql-variables-title"/> for details.
+ <replaceable class="parameter">name</replaceable>. See
+ <xref linkend="app-psql-variables"/>, above, for details.
</para>
</listitem>
</varlistentry>
</refsect1>
- <refsect1 id="app-psql-environment">
- <title id="app-psql-environment-title">Environment</title>
+ <refsect1 id="app-psql-environment" xreflabel="Environment">
+ <title>Environment</title>
<variablelist>
</refsect1>
- <refsect1 id="app-psql-examples">
- <title id="app-psql-examples-title">Examples</title>
+ <refsect1 id="app-psql-examples" xreflabel="Examples">
+ <title>Examples</title>
<para>
The first example shows how to spread a command over several lines of
updates, or deletes on the table; whereas a standard index rebuild
locks out writes (but not reads) on the table until it's done.
There are several caveats to be aware of when using this option
- — see <xref linkend="sql-reindex-concurrently"
- endterm="sql-reindex-concurrently-title"/>.
+ — see <xref linkend="sql-reindex-concurrently"/> below.
</para>
<para>
For temporary tables, <command>REINDEX</command> is always
Each individual partition can be reindexed separately instead.
</para>
- <refsect2 id="sql-reindex-concurrently">
- <title id="sql-reindex-concurrently-title">Rebuilding Indexes Concurrently</title>
+ <refsect2 id="sql-reindex-concurrently" xreflabel="Rebuilding Indexes Concurrently">
+ <title>Rebuilding Indexes Concurrently</title>
<indexterm zone="sql-reindex-concurrently">
<primary>index</primary>
that is referenced more than once in <literal>FROM</literal> is
computed only once,
unless specified otherwise with <literal>NOT MATERIALIZED</literal>.
- (See <xref linkend="sql-with" endterm="sql-with-title"/> below.)
+ (See <xref linkend="sql-with"/> below.)
</para>
</listitem>
(Each element in the <literal>FROM</literal> list is a real or
virtual table.) If more than one element is specified in the
<literal>FROM</literal> list, they are cross-joined together.
- (See <xref linkend="sql-from" endterm="sql-from-title"/> below.)
+ (See <xref linkend="sql-from"/> below.)
</para>
</listitem>
<para>
If the <literal>WHERE</literal> clause is specified, all rows
that do not satisfy the condition are eliminated from the
- output. (See <xref linkend="sql-where"
- endterm="sql-where-title"/> below.)
+ output. (See <xref linkend="sql-where"/> below.)
</para>
</listitem>
values, and the results of aggregate functions are computed.
If the <literal>HAVING</literal> clause is present, it
eliminates groups that do not satisfy the given condition. (See
- <xref linkend="sql-groupby" endterm="sql-groupby-title"/> and
- <xref linkend="sql-having" endterm="sql-having-title"/> below.)
+ <xref linkend="sql-groupby"/> and
+ <xref linkend="sql-having"/> below.)
</para>
</listitem>
<para>
The actual output rows are computed using the
<command>SELECT</command> output expressions for each selected
- row or row group. (See
- <xref linkend="sql-select-list" endterm="sql-select-list-title"/>
- below.)
+ row or row group. (See <xref linkend="sql-select-list"/> below.)
</para>
</listitem>
result. <literal>SELECT DISTINCT ON</literal> eliminates rows that
match on all the specified expressions. <literal>SELECT ALL</literal>
(the default) will return all candidate rows, including
- duplicates. (See <xref linkend="sql-distinct"
- endterm="sql-distinct-title"/> below.)
+ duplicates. (See <xref linkend="sql-distinct"/> below.)
</para>
</listitem>
eliminating duplicate rows. Notice that <literal>DISTINCT</literal> is
the default behavior here, even though <literal>ALL</literal> is
the default for <command>SELECT</command> itself. (See
- <xref linkend="sql-union" endterm="sql-union-title"/>, <xref
- linkend="sql-intersect" endterm="sql-intersect-title"/>, and
- <xref linkend="sql-except" endterm="sql-except-title"/> below.)
+ <xref linkend="sql-union"/>, <xref linkend="sql-intersect"/>, and
+ <xref linkend="sql-except"/> below.)
</para>
</listitem>
returned rows are sorted in the specified order. If
<literal>ORDER BY</literal> is not given, the rows are returned
in whatever order the system finds fastest to produce. (See
- <xref linkend="sql-orderby" endterm="sql-orderby-title"/> below.)
+ <xref linkend="sql-orderby"/> below.)
</para>
</listitem>
If the <literal>LIMIT</literal> (or <literal>FETCH FIRST</literal>) or <literal>OFFSET</literal>
clause is specified, the <command>SELECT</command> statement
only returns a subset of the result rows. (See <xref
- linkend="sql-limit" endterm="sql-limit-title"/> below.)
+ linkend="sql-limit"/> below.)
</para>
</listitem>
or <literal>FOR KEY SHARE</literal>
is specified, the
<command>SELECT</command> statement locks the selected rows
- against concurrent updates. (See <xref linkend="sql-for-update-share"
- endterm="sql-for-update-share-title"/> below.)
+ against concurrent updates. (See <xref linkend="sql-for-update-share"/>
+ below.)
</para>
</listitem>
</orderedlist>
<refsect1>
<title>Parameters</title>
- <refsect2 id="sql-with">
- <title id="sql-with-title"><literal>WITH</literal> Clause</title>
+ <refsect2 id="sql-with" xreflabel="WITH Clause">
+ <title><literal>WITH</literal> Clause</title>
<para>
The <literal>WITH</literal> clause allows you to specify one or more
</para>
</refsect2>
- <refsect2 id="sql-from">
- <title id="sql-from-title"><literal>FROM</literal> Clause</title>
+ <refsect2 id="sql-from" xreflabel="FROM Clause">
+ <title><literal>FROM</literal> Clause</title>
<para>
The <literal>FROM</literal> clause specifies one or more source
</para>
</refsect2>
- <refsect2 id="sql-where">
- <title id="sql-where-title"><literal>WHERE</literal> Clause</title>
+ <refsect2 id="sql-where" xreflabel="WHERE Clause">
+ <title><literal>WHERE</literal> Clause</title>
<para>
The optional <literal>WHERE</literal> clause has the general form
</para>
</refsect2>
- <refsect2 id="sql-groupby">
- <title id="sql-groupby-title"><literal>GROUP BY</literal> Clause</title>
+ <refsect2 id="sql-groupby" xreflabel="GROUP BY Clause">
+ <title><literal>GROUP BY</literal> Clause</title>
<para>
The optional <literal>GROUP BY</literal> clause has the general form
</para>
</refsect2>
- <refsect2 id="sql-having">
- <title id="sql-having-title"><literal>HAVING</literal> Clause</title>
+ <refsect2 id="sql-having" xreflabel="HAVING Clause">
+ <title><literal>HAVING</literal> Clause</title>
<para>
The optional <literal>HAVING</literal> clause has the general form
</para>
</refsect2>
- <refsect2 id="sql-window">
- <title id="sql-window-title"><literal>WINDOW</literal> Clause</title>
+ <refsect2 id="sql-window" xreflabel="WINDOW Clause">
+ <title><literal>WINDOW</literal> Clause</title>
<para>
The optional <literal>WINDOW</literal> clause has the general form
<para>
The elements of the <literal>PARTITION BY</literal> list are interpreted in
- much the same fashion as elements of a
- <xref linkend="sql-groupby" endterm="sql-groupby-title"/>, except that
+ much the same fashion as elements of a <link
+ linkend="sql-groupby"><literal>GROUP BY</literal></link> clause, except that
they are always simple expressions and never the name or number of an
output column.
Another difference is that these expressions can contain aggregate
<para>
Similarly, the elements of the <literal>ORDER BY</literal> list are interpreted
- in much the same fashion as elements of an
- <xref linkend="sql-orderby" endterm="sql-orderby-title"/>, except that
+ in much the same fashion as elements of a statement-level <link
+ linkend="sql-orderby"><literal>ORDER BY</literal></link> clause, except that
the expressions are always taken as simple expressions and never the name
or number of an output column.
</para>
<para>
The purpose of a <literal>WINDOW</literal> clause is to specify the
behavior of <firstterm>window functions</firstterm> appearing in the query's
- <xref linkend="sql-select-list" endterm="sql-select-list-title"/> or
- <xref linkend="sql-orderby" endterm="sql-orderby-title"/>. These functions
+ <link linkend="sql-select-list"><command>SELECT</command> list</link> or
+ <link linkend="sql-orderby"><literal>ORDER BY</literal></link> clause.
+ These functions
can reference the <literal>WINDOW</literal> clause entries by name
in their <literal>OVER</literal> clauses. A <literal>WINDOW</literal> clause
entry does not have to be referenced anywhere, however; if it is not
</para>
</refsect2>
- <refsect2 id="sql-select-list">
- <title id="sql-select-list-title"><command>SELECT</command> List</title>
+ <refsect2 id="sql-select-list" xreflabel="SELECT List">
+ <title><command>SELECT</command> List</title>
<para>
The <command>SELECT</command> list (between the key words
</note>
</refsect2>
- <refsect2 id="sql-distinct">
- <title id="sql-distinct-title"><literal>DISTINCT</literal> Clause</title>
+ <refsect2 id="sql-distinct" xreflabel="DISTINCT Clause">
+ <title><literal>DISTINCT</literal> Clause</title>
<para>
If <literal>SELECT DISTINCT</literal> is specified, all duplicate rows are
</para>
</refsect2>
- <refsect2 id="sql-union">
- <title id="sql-union-title"><literal>UNION</literal> Clause</title>
+ <refsect2 id="sql-union" xreflabel="UNION Clause">
+ <title><literal>UNION</literal> Clause</title>
<para>
The <literal>UNION</literal> clause has this general form:
</para>
</refsect2>
- <refsect2 id="sql-intersect">
- <title id="sql-intersect-title"><literal>INTERSECT</literal> Clause</title>
+ <refsect2 id="sql-intersect" xreflabel="INTERSECT Clause">
+ <title><literal>INTERSECT</literal> Clause</title>
<para>
The <literal>INTERSECT</literal> clause has this general form:
</para>
</refsect2>
- <refsect2 id="sql-except">
- <title id="sql-except-title"><literal>EXCEPT</literal> Clause</title>
+ <refsect2 id="sql-except" xreflabel="EXCEPT Clause">
+ <title><literal>EXCEPT</literal> Clause</title>
<para>
The <literal>EXCEPT</literal> clause has this general form:
</para>
</refsect2>
- <refsect2 id="sql-orderby">
- <title id="sql-orderby-title"><literal>ORDER BY</literal> Clause</title>
+ <refsect2 id="sql-orderby" xreflabel="ORDER BY Clause">
+ <title><literal>ORDER BY</literal> Clause</title>
<para>
The optional <literal>ORDER BY</literal> clause has this general form:
</para>
</refsect2>
- <refsect2 id="sql-limit">
- <title id="sql-limit-title"><literal>LIMIT</literal> Clause</title>
+ <refsect2 id="sql-limit" xreflabel="LIMIT Clause">
+ <title><literal>LIMIT</literal> Clause</title>
<para>
The <literal>LIMIT</literal> clause consists of two independent
</para>
</refsect2>
- <refsect2 id="sql-for-update-share">
- <title id="sql-for-update-share-title">The Locking Clause</title>
+ <refsect2 id="sql-for-update-share" xreflabel="The Locking Clause">
+ <title>The Locking Clause</title>
<para>
<literal>FOR UPDATE</literal>, <literal>FOR NO KEY UPDATE</literal>, <literal>FOR SHARE</literal>
used by <productname>MySQL</productname>. The SQL:2008 standard
has introduced the clauses <literal>OFFSET ... FETCH {FIRST|NEXT}
...</literal> for the same functionality, as shown above
- in <xref linkend="sql-limit" endterm="sql-limit-title"/>. This
+ in <xref linkend="sql-limit"/>. This
syntax is also used by <productname>IBM DB2</productname>.
(Applications written for <productname>Oracle</productname>
frequently use a workaround involving the automatically
<para>
A table expression allowing columns from other tables to appear in
the <literal>WHERE</literal> condition and update expressions. This
- uses the same syntax as the <xref linkend="sql-from"
- endterm="sql-from-title"/> of a <command>SELECT</command> statement;
+ uses the same syntax as the <link
+ linkend="sql-from"><literal>FROM</literal></link> clause of
+ a <command>SELECT</command> statement;
for example, an alias for the table name can be specified. Do not
repeat the target table as a <replaceable>from_item</replaceable>
unless you intend a self-join (in which case it must appear with
rows. This expression can refer to the columns of the
<command>VALUES</command> result as <literal>column1</literal>, <literal>column2</literal>,
etc. For more details see
- <xref linkend="sql-orderby" endterm="sql-orderby-title"/>.
+ <xref linkend="sql-orderby"/>
+ in the <xref linkend="sql-select"/> documentation.
</para>
</listitem>
</varlistentry>
<listitem>
<para>
A sorting operator. For details see
- <xref linkend="sql-orderby" endterm="sql-orderby-title"/>.
+ <xref linkend="sql-orderby"/>
+ in the <xref linkend="sql-select"/> documentation.
</para>
</listitem>
</varlistentry>
<listitem>
<para>
The maximum number of rows to return. For details see
- <xref linkend="sql-limit" endterm="sql-limit-title"/>.
+ <xref linkend="sql-limit"/>
+ in the <xref linkend="sql-select"/> documentation.
</para>
</listitem>
</varlistentry>
<listitem>
<para>
The number of rows to skip before starting to return rows.
- For details see
- <xref linkend="sql-limit" endterm="sql-limit-title"/>.
+ For details see <xref linkend="sql-limit"/>
+ in the <xref linkend="sql-select"/> documentation.
</para>
</listitem>
</varlistentry>