Name
UPDATE Statement
Synopsis
The UPDATE statement changes existing data in a table. Use great caution when issuing an UPDATE statement without a WHERE clause, since the statement then affects every row in the entire table.
Platform |
Command |
DB2 |
Supported, with variations |
MySQL |
Supported, with variations |
Oracle |
Supported, with variations |
PostgreSQL |
Supported, with variations |
SQL Server |
Supported, with variations |
SQL2003 Syntax
UPDATE [ONLY] {table_name
|view_name
} SET {{column_name
= { ARRAY [array_val
[,...] ] | DEFAULT | NULL |scalar_expression
},column_name
= { ARRAY | DEFAULT | NULL |scalar_expression
} [,...] } | ROW =row_expression
} [ WHEREsearch_condition
| WHERE CURRENT OFcursor_name
]
Keywords
- ONLY
Restricts cascading of the updated values to any subtables of the target table or view. ONLY effects only typed (object-oriented) tables and views. If used with a nontyped table or view, it causes an error.
-
table_name
|view_name
The target table or view of the update statement. You need appropriate permissions on the target according to the rules of the platform. Updates against views often have special rules. Generally, it is only advisable to perform an UPDATE against a view if the view is representative of a single table.
- SET
Assigns a specific value to a column or row.
-
column_name
Used in conjunction with SET, as in SET
column1= 'foo'
. Allows you to set a new value for the specified column. You can update as many columns as you like in one statement, though you ...
Get SQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.