1 .\\" auto-generated by docbook2man-spec $Revision: 1.1 $
2 .TH "UPDATE" "7" "2003-11-02" "SQL - Language Statements" "SQL Commands"
4 UPDATE \- update rows of a table
9 UPDATE [ ONLY ] \fItable\fR SET \fIcolumn\fR = { \fIexpression\fR | DEFAULT } [, ...]
10 [ FROM \fIfromlist\fR ]
11 [ WHERE \fIcondition\fR ]
16 \fBUPDATE\fR changes the values of the specified
17 columns in all rows that satisfy the condition. Only the columns to
18 be modified need be mentioned in the statement; columns not explicitly
19 SET retain their previous values.
21 By default, \fBUPDATE\fR will update rows in the
22 specified table and all its subtables. If you wish to only update
23 the specific table mentioned, you must use the ONLY
26 You must have the UPDATE privilege on the table
27 to update it, as well as the SELECT
28 privilege to any table whose values are read in the
34 The name (optionally schema-qualified) of the table to update.
37 The name of a column in \fItable\fR.
39 \fB\fIexpression\fB\fR
40 An expression to assign to the column. The expression may use the
41 old values of this and other columns in the table.
44 Set the column to its default value (which will be NULL if no
45 specific default expression has been assigned to it).
48 A list of table expressions, allowing columns from other tables
49 to appear in the WHERE condition and the update expressions.
52 An expression that returns a value of type \fBboolean\fR.
53 Only rows for which this expression returns true
57 On successful completion, an \fBUPDATE\fR command returns a command
64 The \fIcount\fR is the number
65 of rows updated. If \fIcount\fR is
66 0, no rows matched the \fIcondition\fR (this is not considered
70 Change the word Drama to Dramatic in the
71 column \fBkind\fR of the table films:
74 UPDATE films SET kind = 'Dramatic' WHERE kind = 'Drama';
78 Adjust temperature entries and reset precipitation to its default
79 value in one row of the table weather:
82 UPDATE weather SET temp_lo = temp_lo+1, temp_hi = temp_lo+15, prcp = DEFAULT
83 WHERE city = 'San Francisco' AND date = '2003-07-03';
88 This command conforms to the SQL standard. The