summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-07-03 16:34:26 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-07-03 16:34:26 +0000
commit455891bf96f6ee3dda9150fe83af2be5e86a572b (patch)
treed29465046a93c84445b8160e5af83899440330a2 /doc/src
parent7b1885bf989781b12bda847b98c89476efb894c9 (diff)
Code review for UPDATE tab SET col = DEFAULT patch ... whack it around
so it has some chance of working in rules ...
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/ref/insert.sgml6
-rw-r--r--doc/src/sgml/ref/update.sgml37
2 files changed, 29 insertions, 14 deletions
diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml
index d2e29a87577..cbb0d279bd2 100644
--- a/doc/src/sgml/ref/insert.sgml
+++ b/doc/src/sgml/ref/insert.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/insert.sgml,v 1.22 2003/04/26 23:56:51 petere Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/insert.sgml,v 1.23 2003/07/03 16:32:03 tgl Exp $
PostgreSQL documentation
-->
@@ -33,7 +33,7 @@ INSERT INTO <replaceable class="PARAMETER">table</replaceable> [ ( <replaceable
<para>
The columns in the target list may be listed in any order.
Each column not present in the target list will be inserted
- using a default value, either a declared default value
+ using a default value, either its declared default value
or null.
</para>
@@ -77,7 +77,7 @@ INSERT INTO <replaceable class="PARAMETER">table</replaceable> [ ( <replaceable
<term><literal>DEFAULT VALUES</literal></term>
<listitem>
<para>
- All columns will be filled their default values.
+ All columns will be filled with their default values.
</para>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/update.sgml b/doc/src/sgml/ref/update.sgml
index 02cc07b0bd4..1fe85b995ed 100644
--- a/doc/src/sgml/ref/update.sgml
+++ b/doc/src/sgml/ref/update.sgml
@@ -1,5 +1,5 @@
<!--
-$Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.22 2003/06/25 04:19:24 momjian Exp $
+$Header: /cvsroot/pgsql/doc/src/sgml/ref/update.sgml,v 1.23 2003/07/03 16:32:12 tgl Exp $
PostgreSQL documentation
-->
@@ -28,7 +28,8 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
<para>
<command>UPDATE</command> changes the values of the specified
columns in all rows that satisfy the condition. Only the columns to
- be modified need appear as columns in the statement.
+ be modified need be mentioned in the statement; columns not explicitly
+ <literal>SET</> retain their previous values.
</para>
<para>
@@ -41,8 +42,9 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
<para>
You must have the <literal>UPDATE</literal> privilege on the table
to update it, as well as the <literal>SELECT</literal>
- privilege to any table whose values are read in the <replaceable
- class="parameter">condition</replaceable>.
+ privilege to any table whose values are read in the
+ <replaceable class="parameter">expression</replaceable>s or
+ <replaceable class="parameter">condition</replaceable>.
</para>
</refsect1>
@@ -72,7 +74,8 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
<term><replaceable class="PARAMETER">expression</replaceable></term>
<listitem>
<para>
- An expression or value to assign to the column.
+ An expression to assign to the column. The expression may use the
+ old values of this and other columns in the table.
</para>
</listitem>
</varlistentry>
@@ -81,7 +84,8 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
<term><literal>DEFAULT</literal></term>
<listitem>
<para>
- This column will be filled with its default value.
+ Set the column to its default value (which will be NULL if no
+ specific default expression has been assigned to it).
</para>
</listitem>
</varlistentry>
@@ -91,7 +95,7 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
<listitem>
<para>
A list of table expressions, allowing columns from other tables
- to appear in the <literal>WHERE</> condition.
+ to appear in the <literal>WHERE</> condition and the update expressions.
</para>
</listitem>
</varlistentry>
@@ -100,9 +104,9 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
<term><replaceable class="PARAMETER">condition</replaceable></term>
<listitem>
<para>
- A value expression that returns a value of type
- <type>boolean</type> that determines the rows which are to be
- updated.
+ An expression that returns a value of type <type>boolean</type>.
+ Only rows for which this expression returns <literal>true</>
+ will be updated.
</para>
</listitem>
</varlistentry>
@@ -135,9 +139,20 @@ UPDATE [ ONLY ] <replaceable class="PARAMETER">table</replaceable> SET <replacea
column <structfield>kind</> of the table <literal>films</literal>:
<programlisting>
-UPDATE filme SET kind = 'Dramatic' WHERE kind = 'Drama';
+UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama';
</programlisting>
</para>
+
+ <para>
+ Adjust temperature entries and reset precipitation to its default
+ value in one row of the table <literal>weather</literal>:
+
+<programlisting>
+UPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT
+ WHERE city = 'San Francisco' AND date = '2003-07-03';
+</programlisting>
+ </para>
+
</refsect1>
<refsect1>