|
1 | 1 | <!--
|
2 |
| -$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.82 2005/03/10 23:21:20 tgl Exp $ |
| 2 | +$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.83 2005/04/08 00:59:58 neilc Exp $ |
3 | 3 | PostgreSQL documentation
|
4 | 4 | -->
|
5 | 5 |
|
@@ -1011,42 +1011,21 @@ SELECT 2+2;
|
1011 | 1011 | </para>
|
1012 | 1012 |
|
1013 | 1013 | <para>
|
1014 |
| - A less obvious use is to abbreviate a normal |
1015 |
| - <command>SELECT</command> from tables: |
| 1014 | + Note that if a <literal>FROM</literal> clause is not specified, |
| 1015 | + the query cannot reference any database tables. For example, the |
| 1016 | + following query is invalid: |
1016 | 1017 | <programlisting>
|
1017 | 1018 | SELECT distributors.* WHERE distributors.name = 'Westward';
|
1018 |
| - |
1019 |
| - did | name |
1020 |
| ------+---------- |
1021 |
| - 108 | Westward |
1022 |
| -</programlisting> |
1023 |
| - This works because an implicit <literal>FROM</literal> item is |
1024 |
| - added for each table that is referenced in other parts of the |
1025 |
| - <command>SELECT</command> statement but not mentioned in |
1026 |
| - <literal>FROM</literal>. |
1027 |
| - </para> |
1028 |
| - |
1029 |
| - <para> |
1030 |
| - While this is a convenient shorthand, it's easy to misuse. For |
1031 |
| - example, the command |
1032 |
| -<programlisting> |
1033 |
| -SELECT distributors.* FROM distributors d; |
1034 |
| -</programlisting> |
1035 |
| - is probably a mistake; most likely the user meant |
1036 |
| -<programlisting> |
1037 |
| -SELECT d.* FROM distributors d; |
1038 |
| -</programlisting> |
1039 |
| - rather than the unconstrained join |
1040 |
| -<programlisting> |
1041 |
| -SELECT distributors.* FROM distributors d, distributors distributors; |
1042 | 1019 | </programlisting>
|
1043 |
| - that he will actually get. To help detect this sort of mistake, |
1044 |
| - <productname>PostgreSQL</productname> will warn if the |
1045 |
| - implicit-<literal>FROM</literal> feature is used in a |
1046 |
| - <command>SELECT</command> statement that also contains an explicit |
1047 |
| - <literal>FROM</literal> clause. Also, it is possible to disable |
1048 |
| - the implicit-<literal>FROM</literal> feature by setting the |
1049 |
| - <xref linkend="guc-add-missing-from"> parameter to false. |
| 1020 | + <productname>PostgreSQL</productname> releases prior to |
| 1021 | + 8.1 would accept queries of this form, and add an implicit entry |
| 1022 | + to the query's <literal>FROM</literal> clause for each table |
| 1023 | + referenced by the query. This is no longer the default behavior, |
| 1024 | + because it does not comply with the SQL standard, and is |
| 1025 | + considered by many to be error-prone. For compatibility with |
| 1026 | + applications that rely on this behavior the <xref |
| 1027 | + linkend="guc-add-missing-from"> configuration variable can be |
| 1028 | + enabled. |
1050 | 1029 | </para>
|
1051 | 1030 | </refsect2>
|
1052 | 1031 |
|
|
0 commit comments