11<!--
2- $Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.22 2003/06/25 04:19:24 momjian Exp $
2+ $Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.23 2003/07/03 16:32:12 tgl Exp $
33PostgreSQL documentation
44-->
55
@@ -28,7 +28,8 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
2828 <para>
2929 <command>UPDATE</command> changes the values of the specified
3030 columns in all rows that satisfy the condition. Only the columns to
31- be modified need appear as columns in the statement.
31+ be modified need be mentioned in the statement; columns not explicitly
32+ <literal>SET</> retain their previous values.
3233 </para>
3334
3435 <para>
@@ -41,8 +42,9 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
4142 <para>
4243 You must have the <literal>UPDATE</literal> privilege on the table
4344 to update it, as well as the <literal>SELECT</literal>
44- privilege to any table whose values are read in the <replaceable
45- class="parameter">condition</replaceable>.
45+ privilege to any table whose values are read in the
46+ <replaceable class="parameter">expression</replaceable>s or
47+ <replaceable class="parameter">condition</replaceable>.
4648 </para>
4749 </refsect1>
4850
@@ -72,7 +74,8 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
7274 <term><replaceable class="PARAMETER">expression</replaceable></term>
7375 <listitem>
7476 <para>
75- An expression or value to assign to the column.
77+ An expression to assign to the column. The expression may use the
78+ old values of this and other columns in the table.
7679 </para>
7780 </listitem>
7881 </varlistentry>
@@ -81,7 +84,8 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
8184 <term><literal>DEFAULT</literal></term>
8285 <listitem>
8386 <para>
84- This column will be filled with its default value.
87+ Set the column to its default value (which will be NULL if no
88+ specific default expression has been assigned to it).
8589 </para>
8690 </listitem>
8791 </varlistentry>
@@ -91,7 +95,7 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
9195 <listitem>
9296 <para>
9397 A list of table expressions, allowing columns from other tables
94- to appear in the <literal>WHERE</> condition.
98+ to appear in the <literal>WHERE</> condition and the update expressions .
9599 </para>
96100 </listitem>
97101 </varlistentry>
@@ -100,9 +104,9 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
100104 <term><replaceable class="PARAMETER">condition</replaceable></term>
101105 <listitem>
102106 <para>
103- A value expression that returns a value of type
104- <type>boolean</type> that determines the rows whichare to be
105- updated.
107+ An expression that returns a value of type <type>boolean</type>.
108+ Only rowsfor whichthis expression returns <literal>true</>
109+ will be updated.
106110 </para>
107111 </listitem>
108112 </varlistentry>
@@ -135,9 +139,20 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
135139 column <structfield>kind</> of the table <literal>films</literal>:
136140
137141<programlisting>
138- UPDATEfilme SET kind = 'Dramatic' WHERE kind = 'Drama';
142+ UPDATEfilms SET kind = 'Dramatic' WHERE kind = 'Drama';
139143</programlisting>
140144 </para>
145+
146+ <para>
147+ Adjust temperature entries and reset precipitation to its default
148+ value in one row of the table <literal>weather</literal>:
149+
150+ <programlisting>
151+ UPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT
152+ WHERE city = 'San Francisco' AND date = '2003-07-03';
153+ </programlisting>
154+ </para>
155+
141156 </refsect1>
142157
143158 <refsect1>