mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
doc: adjust UPDATE/DELETE's FROM/USING to match SELECT's FROM
Previously the syntax and wording were unclear. Reported-by: Alexey Bashtanov Discussion: https://postgr.es/m/968d4724-8e58-788f-7c45-f7b1813824cc@imap.cc Backpatch-through: 9.5
This commit is contained in:
parent
e48ff22d39
commit
f40f44f1e7
@ -23,7 +23,7 @@ PostgreSQL documentation
|
|||||||
<synopsis>
|
<synopsis>
|
||||||
[ WITH [ RECURSIVE ] <replaceable class="parameter">with_query</replaceable> [, ...] ]
|
[ WITH [ RECURSIVE ] <replaceable class="parameter">with_query</replaceable> [, ...] ]
|
||||||
DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table_name</replaceable> [ * ] [ [ AS ] <replaceable class="parameter">alias</replaceable> ]
|
DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table_name</replaceable> [ * ] [ [ AS ] <replaceable class="parameter">alias</replaceable> ]
|
||||||
[ USING <replaceable class="PARAMETER">using_list</replaceable> ]
|
[ USING <replaceable class="parameter">from_item</replaceable> [, ...] ]
|
||||||
[ WHERE <replaceable class="PARAMETER">condition</replaceable> | WHERE CURRENT OF <replaceable class="PARAMETER">cursor_name</replaceable> ]
|
[ WHERE <replaceable class="PARAMETER">condition</replaceable> | WHERE CURRENT OF <replaceable class="PARAMETER">cursor_name</replaceable> ]
|
||||||
[ RETURNING * | <replaceable class="parameter">output_expression</replaceable> [ [ AS ] <replaceable class="parameter">output_name</replaceable> ] [, ...] ]
|
[ RETURNING * | <replaceable class="parameter">output_expression</replaceable> [ [ AS ] <replaceable class="parameter">output_name</replaceable> ] [, ...] ]
|
||||||
</synopsis>
|
</synopsis>
|
||||||
@ -118,17 +118,17 @@ DELETE FROM [ ONLY ] <replaceable class="PARAMETER">table_name</replaceable> [ *
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><replaceable class="PARAMETER">using_list</replaceable></term>
|
<term><replaceable class="parameter">from_item</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A list of table expressions, allowing columns from other tables
|
A table expression allowing columns from other tables to appear
|
||||||
to appear in the <literal>WHERE</> condition. This is similar
|
in the <literal>WHERE</literal> condition. This uses the same
|
||||||
to the list of tables that can be specified in the <xref
|
syntax as the <xref linkend="sql-from" endterm="sql-from-title">
|
||||||
linkend="sql-from" endterm="sql-from-title"> of a
|
of a <command>SELECT</command> statement; for example, an alias
|
||||||
<command>SELECT</command> statement; for example, an alias for
|
for the table name can be specified. Do not repeat the target
|
||||||
the table name can be specified. Do not repeat the target table
|
table as a <replaceable class="parameter">from_item</replaceable>
|
||||||
in the <replaceable class="PARAMETER">using_list</replaceable>,
|
unless you wish to set up a self-join (in which case it must appear
|
||||||
unless you wish to set up a self-join.
|
with an alias in the <replaceable>from_item</replaceable>).
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -27,7 +27,7 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table_name</replaceable> [ * ] [
|
|||||||
( <replaceable class="PARAMETER">column_name</replaceable> [, ...] ) = ( { <replaceable class="PARAMETER">expression</replaceable> | DEFAULT } [, ...] ) |
|
( <replaceable class="PARAMETER">column_name</replaceable> [, ...] ) = ( { <replaceable class="PARAMETER">expression</replaceable> | DEFAULT } [, ...] ) |
|
||||||
( <replaceable class="PARAMETER">column_name</replaceable> [, ...] ) = ( <replaceable class="PARAMETER">sub-SELECT</replaceable> )
|
( <replaceable class="PARAMETER">column_name</replaceable> [, ...] ) = ( <replaceable class="PARAMETER">sub-SELECT</replaceable> )
|
||||||
} [, ...]
|
} [, ...]
|
||||||
[ FROM <replaceable class="PARAMETER">from_list</replaceable> ]
|
[ FROM <replaceable class="parameter">from_item</replaceable> [, ...] ]
|
||||||
[ WHERE <replaceable class="PARAMETER">condition</replaceable> | WHERE CURRENT OF <replaceable class="PARAMETER">cursor_name</replaceable> ]
|
[ WHERE <replaceable class="PARAMETER">condition</replaceable> | WHERE CURRENT OF <replaceable class="PARAMETER">cursor_name</replaceable> ]
|
||||||
[ RETURNING * | <replaceable class="parameter">output_expression</replaceable> [ [ AS ] <replaceable class="parameter">output_name</replaceable> ] [, ...] ]
|
[ RETURNING * | <replaceable class="parameter">output_expression</replaceable> [ [ AS ] <replaceable class="parameter">output_name</replaceable> ] [, ...] ]
|
||||||
</synopsis>
|
</synopsis>
|
||||||
@ -164,17 +164,17 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table_name</replaceable> [ * ] [
|
|||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><replaceable class="PARAMETER">from_list</replaceable></term>
|
<term><replaceable class="parameter">from_item</replaceable></term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
A list of table expressions, allowing columns from other tables
|
A table expression allowing columns from other tables to appear in
|
||||||
to appear in the <literal>WHERE</> condition and the update
|
the <literal>WHERE</literal> condition and update expressions. This
|
||||||
expressions. This is similar to the list of tables that can be
|
uses the same syntax as the <xref linkend="sql-from"
|
||||||
specified in the <xref linkend="sql-from"
|
endterm="sql-from-title"> of a <command>SELECT</command> statement;
|
||||||
endterm="sql-from-title"> of a <command>SELECT</command>
|
for example, an alias for the table name can be specified. Do not
|
||||||
statement. Note that the target table must not appear in the
|
repeat the target table as a <replaceable>from_item</replaceable>
|
||||||
<replaceable>from_list</>, unless you intend a self-join (in which
|
unless you intend a self-join (in which case it must appear with
|
||||||
case it must appear with an alias in the <replaceable>from_list</>).
|
an alias in the <replaceable>from_item</replaceable>).
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -264,7 +264,7 @@ UPDATE <replaceable class="parameter">count</replaceable>
|
|||||||
<para>
|
<para>
|
||||||
When a <literal>FROM</> clause is present, what essentially happens
|
When a <literal>FROM</> clause is present, what essentially happens
|
||||||
is that the target table is joined to the tables mentioned in the
|
is that the target table is joined to the tables mentioned in the
|
||||||
<replaceable>from_list</replaceable>, and each output row of the join
|
<replaceable>from_item</replaceable> list, and each output row of the join
|
||||||
represents an update operation for the target table. When using
|
represents an update operation for the target table. When using
|
||||||
<literal>FROM</> you should ensure that the join
|
<literal>FROM</> you should ensure that the join
|
||||||
produces at most one output row for each row to be modified. In
|
produces at most one output row for each row to be modified. In
|
||||||
|
Loading…
x
Reference in New Issue
Block a user