UPDATE

The UPDATE statement overwrites the values of map entries that match the condition in a given WHERE clause. However, you cannot update keys in map entries.

This statement is not atomic and updates are never rolled back. If this statement is canceled for any reason, some values that match the condition may be updated and some may remain unchanged.

Syntax Summary

This code block is a quick reference with all the parameters that you can use with the UPDATE statement.

See some practical examples.

UPDATE table_name [ [ AS ] alias ]
SET { column_name = expression } [, ...]
[ WHERE condition ]

Parameters

The UPDATE statement accepts the following required parameters.

Parameter Description Example

expression

The columns to select such as names of columns or the * wildcard.

WHERE condition

An optional clause that, if given, indicates the conditions that rows must satisfy to be selected. condition is an expression that is evaluated for each row. If the expression is true, the row is selected. This expression is evaluated before grouping.

Examples

This section lists some example SQL queries that show you how to use the UPDATE statement.

Update Columns by Name

You can overwrite the values in columns by name, using the SET clause.

For example, in a map that contains Employee objects as values with the following structure:

Name

Type

startDate

integer

amount

integer

title

string

department

string

You can update the values of the Employee.department field:

UPDATE employees SET department = 'engineering' WHERE title = 'developer';

Whether you can access nested fields like this in objects depends on how your map entries are serialized: