Name

UPDATE Statement

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

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}
[ WHERE search_condition | WHERE CURRENT OF cursor_name ]

Keywords

ONLY

Restricts cascading of the updated values to any subtables of the target table or view. ONLY affects 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 advisable to perform an UPDATE against a view only 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 cannot update the same column more than once in a single statement. ...

Get SQL in a Nutshell, 3rd 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.