Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec25ba6

Browse files
committed
Doc: update queries.sgml for optional subquery aliases.
Commitbcedd8f made subquery aliases optional in the FROM clause.It missed updating this part of the docs, though.
1 parentccc59a8 commitec25ba6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

‎doc/src/sgml/queries.sgml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,6 @@ SELECT * FROM my_table AS m WHERE my_table.a > 5; -- wrong
588588
<programlisting>
589589
SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id;
590590
</programlisting>
591-
Additionally, an alias is required if the table reference is a
592-
subquery (see <xref linkend="queries-subqueries"/>).
593591
</para>
594592

595593
<para>
@@ -639,9 +637,9 @@ SELECT a.* FROM (my_table AS a JOIN your_table AS b ON ...) AS c
639637

640638
<para>
641639
Subqueries specifying a derived table must be enclosed in
642-
parentheses and <emphasis>must</emphasis>be assigned a table
643-
aliasname (as in <xref linkend="queries-table-aliases"/>). For
644-
example:
640+
parentheses. They maybe assigned a table alias name, and optionally
641+
columnaliasnames (as in <xref linkend="queries-table-aliases"/>).
642+
Forexample:
645643
<programlisting>
646644
FROM (SELECT * FROM table1) AS alias_name
647645
</programlisting>
@@ -660,10 +658,18 @@ FROM (SELECT * FROM table1) AS alias_name
660658
FROM (VALUES ('anne', 'smith'), ('bob', 'jones'), ('joe', 'blow'))
661659
AS names(first, last)
662660
</programlisting>
663-
Again, a table alias isrequired. Assigning alias names to the columns
661+
Again, a table alias isoptional. Assigning alias names to the columns
664662
of the <command>VALUES</command> list is optional, but is good practice.
665663
For more information see <xref linkend="queries-values"/>.
666664
</para>
665+
666+
<para>
667+
According to the SQL standard, a table alias name must be supplied
668+
for a subquery. <productname>PostgreSQL</productname>
669+
allows <literal>AS</literal> and the alias to be omitted, but
670+
writing one is good practice in SQL code that might be ported to
671+
another system.
672+
</para>
667673
</sect3>
668674

669675
<sect3 id="queries-tablefunctions">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp