Doc: update queries.sgml for optional subquery aliases.
authorTom Lane
Sun, 27 Nov 2022 17:26:04 +0000 (12:26 -0500)
committerTom Lane
Sun, 27 Nov 2022 17:26:04 +0000 (12:26 -0500)
Commit bcedd8f5f made subquery aliases optional in the FROM clause.
It missed updating this part of the docs, though.

doc/src/sgml/queries.sgml

index 95559ef1ac470eb9063392ca39874e5d56183bf4..47e6369f1a46531842a5ed79a9ff4a03e9424890 100644 (file)
@@ -588,8 +588,6 @@ SELECT * FROM my_table AS m WHERE my_table.a > 5;    -- wrong
 
 SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id;
 
-     Additionally, an alias is required if the table reference is a
-     subquery (see ).
     
 
     
@@ -639,9 +637,9 @@ SELECT a.* FROM (my_table AS a JOIN your_table AS b ON ...) AS c
 
     
      Subqueries specifying a derived table must be enclosed in
-     parentheses and must be assigned a table
-     alias name (as in ).  For
-     example:
+     parentheses.  They may be assigned a table alias name, and optionally
+     column alias names (as in ).
+     For example:
 
 FROM (SELECT * FROM table1) AS alias_name
 
@@ -660,10 +658,18 @@ FROM (SELECT * FROM table1) AS alias_name
 FROM (VALUES ('anne', 'smith'), ('bob', 'jones'), ('joe', 'blow'))
      AS names(first, last)
 
-     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 VALUES list is optional, but is good practice.
      For more information see .
     
+
+    
+     According to the SQL standard, a table alias name must be supplied
+     for a subquery.  PostgreSQL
+     allows AS and the alias to be omitted, but
+     writing one is good practice in SQL code that might be ported to
+     another system.
+