mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
doc: clarify aliasing of VALUES in FROM clauses
The VALUES reference page said that an AS clause was required when
VALUES is used in a FROM clause. This was imprecise because AS is
optional when specifying an alias.
In v14 and v15, a table alias is still required in this case, so state
that explicitly instead. In v16 and later, commit bcedd8f5fc made table
aliases for subqueries in FROM clauses optional, so state that the
table alias is optional there. In all branches, continue to recommend
explicit column aliases as good practice.
Backpatch to all supported versions.
Author: Ian Barwick <barwick@gmail.com>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/CAB8KJ=jrvZdNLLhYSiCgbjLTz2LKEjYw+-HVQkaF+kgk61KtHA@mail.gmail.com
Backpatch-through: 14
This commit is contained in:
@@ -198,10 +198,10 @@ UPDATE employees SET salary = salary * v.increase
|
||||
WHERE employees.depno = v.depno AND employees.sales >= v.target;
|
||||
</programlisting>
|
||||
|
||||
Note that an <literal>AS</literal> clause is required when <command>VALUES</command>
|
||||
is used in a <literal>FROM</literal> clause, just as is true for
|
||||
<command>SELECT</command>. It is not required that the <literal>AS</literal> clause
|
||||
specify names for all the columns, but it's good practice to do so.
|
||||
Note that a table alias is required when <command>VALUES</command> is used in
|
||||
a <literal>FROM</literal> clause, just as is true for <command>SELECT</command>.
|
||||
Assigning alias names to the columns of the <command>VALUES</command> list
|
||||
is optional, but is good practice.
|
||||
(The default column names for <command>VALUES</command> are <literal>column1</literal>,
|
||||
<literal>column2</literal>, etc in <productname>PostgreSQL</productname>, but
|
||||
these names might be different in other database systems.)
|
||||
|
||||
Reference in New Issue
Block a user