mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Code review for UPDATE tab SET col = DEFAULT patch ... whack it around
so it has some chance of working in rules ...
This commit is contained in:
@ -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>
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user