diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-11-27 12:26:04 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-11-27 12:26:04 -0500 |
commit | ec25ba624e9c0168d44c9f6e87872f1e3e6b308f (patch) | |
tree | b3cad9766aec7e0ae715ae209269d07e2ffb60ed | |
parent | ccc59a83cd977608564a6f11ffcb2ec1773a9e94 (diff) | |
download | postgresql-ec25ba624e9c0168d44c9f6e87872f1e3e6b308f.tar.gz postgresql-ec25ba624e9c0168d44c9f6e87872f1e3e6b308f.zip |
Doc: update queries.sgml for optional subquery aliases.
Commit bcedd8f5f made subquery aliases optional in the FROM clause.
It missed updating this part of the docs, though.
-rw-r--r-- | doc/src/sgml/queries.sgml | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml index 95559ef1ac4..47e6369f1a4 100644 --- a/doc/src/sgml/queries.sgml +++ b/doc/src/sgml/queries.sgml @@ -588,8 +588,6 @@ SELECT * FROM my_table AS m WHERE my_table.a > 5; -- wrong <programlisting> SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id; </programlisting> - Additionally, an alias is required if the table reference is a - subquery (see <xref linkend="queries-subqueries"/>). </para> <para> @@ -639,9 +637,9 @@ SELECT a.* FROM (my_table AS a JOIN your_table AS b ON ...) AS c <para> Subqueries specifying a derived table must be enclosed in - parentheses and <emphasis>must</emphasis> be assigned a table - alias name (as in <xref linkend="queries-table-aliases"/>). For - example: + parentheses. They may be assigned a table alias name, and optionally + column alias names (as in <xref linkend="queries-table-aliases"/>). + For example: <programlisting> FROM (SELECT * FROM table1) AS alias_name </programlisting> @@ -660,10 +658,18 @@ FROM (SELECT * FROM table1) AS alias_name FROM (VALUES ('anne', 'smith'), ('bob', 'jones'), ('joe', 'blow')) AS names(first, last) </programlisting> - Again, a table alias is required. Assigning alias names to the columns + Again, a table alias is optional. Assigning alias names to the columns of the <command>VALUES</command> list is optional, but is good practice. For more information see <xref linkend="queries-values"/>. </para> + + <para> + According to the SQL standard, a table alias name must be supplied + for a subquery. <productname>PostgreSQL</productname> + allows <literal>AS</literal> and the alias to be omitted, but + writing one is good practice in SQL code that might be ported to + another system. + </para> </sect3> <sect3 id="queries-tablefunctions"> |