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

Commitc934cf1

Browse files
author
Neil Conway
committed
Add a few more cross-references where appropriate, add more text about
the FROM clause and an example to the UPDATE reference page, and makea few other SGML tweaks.
1 parent9e733ea commitc934cf1

File tree

4 files changed

+63
-29
lines changed

4 files changed

+63
-29
lines changed

‎doc/src/sgml/queries.sgml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.28 2003/11/29 19:51:37 pgsql Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.29 2004/03/03 22:22:24 neilc Exp $ -->
22

33
<chapter id="queries">
44
<title>Queries</title>
@@ -108,8 +108,9 @@ SELECT random();
108108
<title>The <literal>FROM</literal> Clause</title>
109109

110110
<para>
111-
The <literal>FROM</> clause derives a table from one or more other
112-
tables given in a comma-separated table reference list.
111+
The <xref linkend="sql-from" endterm="sql-from-title"> derives a
112+
table from one or more other tables given in a comma-separated
113+
table reference list.
113114
<synopsis>
114115
FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_reference</replaceable> <optional>, ...</optional></optional>
115116
</synopsis>
@@ -677,7 +678,8 @@ SELECT *
677678
</indexterm>
678679

679680
<para>
680-
The syntax of the <literal>WHERE</> clause is
681+
The syntax of the <xref linkend="sql-where"
682+
endterm="sql-where-title"> clause is
681683
<synopsis>
682684
WHERE <replaceable>search_condition</replaceable>
683685
</synopsis>
@@ -783,13 +785,14 @@ SELECT <replaceable>select_list</replaceable>
783785
</synopsis>
784786

785787
<para>
786-
The <literal>GROUP BY</> clause is used to group together those rows in
787-
a table that share the same values in all the columns listed. The
788-
order in which the columns are listed does not matter. The
789-
purpose is to reduce each group of rows sharing common values into
790-
one group row that is representative of all rows in the group.
791-
This is done to eliminate redundancy in the output and/or compute
792-
aggregates that apply to these groups. For instance:
788+
The <xref linkend="sql-groupby" endterm="sql-groupby-title"> is
789+
used to group together those rows in a table that share the same
790+
values in all the columns listed. The order in which the columns
791+
are listed does not matter. The purpose is to reduce each group
792+
of rows sharing common values into one group row that is
793+
representative of all rows in the group. This is done to
794+
eliminate redundancy in the output and/or compute aggregates that
795+
apply to these groups. For instance:
793796
<screen>
794797
<prompt>=></> <userinput>SELECT * FROM test1;</>
795798
x | y
@@ -1058,7 +1061,7 @@ SELECT a AS value, b + c AS sum FROM ...
10581061
<synopsis>
10591062
SELECT DISTINCT <replaceable>select_list</replaceable> ...
10601063
</synopsis>
1061-
(Instead of <literal>DISTINCT</> the word <literal>ALL</literal>
1064+
(Instead of <literal>DISTINCT</> thekeyword <literal>ALL</literal>
10621065
can be used to select the default behavior of retaining all rows.)
10631066
</para>
10641067

‎doc/src/sgml/ref/select.sgml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.74 2003/12/14 00:15:03 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.75 2004/03/03 22:22:24 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -174,7 +174,8 @@ where <replaceable class="parameter">from_item</replaceable> can be one of:
174174
</para>
175175

176176
<para>
177-
<literal>FROM</literal>-clause elements can contain:
177+
The <literal>FROM</literal> clause can contain the following
178+
elements:
178179

179180
<variablelist>
180181
<varlistentry>
@@ -289,16 +290,16 @@ where <replaceable class="parameter">from_item</replaceable> can be one of:
289290
A <literal>JOIN</literal> clause combines two
290291
<literal>FROM</> items. Use parentheses if necessary to
291292
determine the order of nesting. In the absence of parentheses,
292-
<literal>JOIN</literal>s nest left-to-right. In any case
293-
<literal>JOIN</literal> binds more tightly than the commas
294-
separating <literal>FROM</> items.
293+
<literal>JOIN</literal>s nest left-to-right. In any case
294+
<literal>JOIN</literal> binds more tightly than the commas
295+
separating <literal>FROM</> items.
295296
</para>
296297

297298
<para>
298299
<literal>CROSS JOIN</> and <literal>INNER JOIN</literal>
299300
produce a simple Cartesian product, the same result as you get from
300301
listing the two items at the top level of <literal>FROM</>,
301-
but restricted by the join condition (if any).
302+
but restricted by the join condition (if any).
302303
<literal>CROSS JOIN</> is equivalent to <literal>INNER JOIN ON
303304
(TRUE)</>, that is, no rows are removed by qualification.
304305
These join types are just a notational convenience, since they
@@ -647,7 +648,7 @@ SELECT name FROM distributors ORDER BY code;
647648
<literal>INTERSECT</>, or <literal>EXCEPT</> clause may only
648649
specify an output column name or number, not an expression.
649650
</para>
650-
651+
651652
<para>
652653
If an <literal>ORDER BY</> expression is a simple name that
653654
matches both a result column name and an input column name,

‎doc/src/sgml/ref/update.sgml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.27 2003/11/29 19:51:39 pgsql Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.28 2004/03/03 22:22:24 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -32,8 +32,8 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
3232
<para>
3333
<command>UPDATE</command> changes the values of the specified
3434
columns in all rows that satisfy the condition. Only the columns to
35-
be modified need be mentioned in thestatement; columns not explicitly
36-
<literal>SET</> retain their previous values.
35+
be modified need be mentioned in the<literal>SET</literal> clause;
36+
columns not explicitly modified retain their previous values.
3737
</para>
3838

3939
<para>
@@ -43,6 +43,14 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
4343
clause.
4444
</para>
4545

46+
<para>
47+
There are two ways to modify a table using information contained in
48+
other tables in the database: using sub-selects, or specifying
49+
additional tables in the <literal>FROM</literal> clause. Which
50+
technique is more appropriate depends on the specific
51+
circumstances.
52+
</para>
53+
4654
<para>
4755
You must have the <literal>UPDATE</literal> privilege on the table
4856
to update it, as well as the <literal>SELECT</literal>
@@ -99,7 +107,12 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
99107
<listitem>
100108
<para>
101109
A list of table expressions, allowing columns from other tables
102-
to appear in the <literal>WHERE</> condition and the update expressions.
110+
to appear in the <literal>WHERE</> condition and the update
111+
expressions. This is similar to the list of tables that can be
112+
specified in the <xref linkend="sql-from"
113+
endterm="sql-from-title"> of a <command>SELECT</command>
114+
statement; for example, an alias for the table name can be
115+
specified.
103116
</para>
104117
</listitem>
105118
</varlistentry>
@@ -139,7 +152,7 @@ UPDATE <replaceable class="parameter">count</replaceable>
139152

140153
<para>
141154
Change the word <literal>Drama</> to <literal>Dramatic</> in the
142-
column <structfield>kind</> of the table <literal>films</literal>:
155+
column <structfield>kind</> of the table <structname>films</structname>:
143156

144157
<programlisting>
145158
UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama';
@@ -148,21 +161,38 @@ UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama';
148161

149162
<para>
150163
Adjust temperature entries and reset precipitation to its default
151-
value in one row of the table <literal>weather</literal>:
164+
value in one row of the table <structname>weather</structname>:
152165

153166
<programlisting>
154167
UPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT
155168
WHERE city = 'San Francisco' AND date = '2003-07-03';
156169
</programlisting>
157170
</para>
158171

172+
<para>
173+
Increment the sales count of the salesperson who manages the
174+
account for Acme Corporation, using the <literal>FROM</literal>
175+
clause syntax:
176+
<programlisting>
177+
UPDATE employees SET sales_count = sales_count + 1 FROM accounts
178+
WHERE accounts.name = 'Acme Corporation'
179+
AND employees.id = accounts.sales_person;
180+
</programlisting>
181+
182+
Perform the same operation, using a sub-select in the
183+
<literal>WHERE</literal> clause:
184+
<programlisting>
185+
UPDATE employees SET sales_count = sales_count + 1 WHERE id =
186+
(SELECT sales_person FROM accounts WHERE name = 'Acme Corporation');
187+
</programlisting>
188+
</para>
159189
</refsect1>
160190

161191
<refsect1>
162192
<title>Compatibility</title>
163193

164194
<para>
165-
This command conforms to the SQL standard. The
195+
This command conforms to the<acronym>SQL</acronym> standard. The
166196
<literal>FROM</literal> clause is a
167197
<productname>PostgreSQL</productname> extension.
168198
</para>

‎doc/src/sgml/trigger.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.34 2004/01/22 19:50:21 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.35 2004/03/03 22:22:24 neilc Exp $
33
-->
44

55
<chapter id="triggers">
@@ -449,9 +449,9 @@ typedef struct Trigger
449449

450450
<para>
451451
The function <function>trigf</> reports the number of rows in the
452-
table <literal>ttest</> and skips the actual operation if the
452+
table <structname>ttest</> and skips the actual operation if the
453453
command attempts to insert a null value into the column
454-
<literal>x</>. (So the trigger acts as a not-null constraint but
454+
<structfield>x</>. (So the trigger acts as a not-null constraint but
455455
doesn't abort the transaction.)
456456
</para>
457457

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp