Skip to main content
Version: 6.0-SNAPSHOT

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.

note

This statement is not atomic. If it fails, a part of the rows might be updated and another part might 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.

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

Parameters​

The UPDATE statement accepts the following required parameters.

ParameterDescriptionExample
column_nameThe name of column to set value for.Update Columns by Name
expressionThe value to assign. Can be a literal, parameter, or an expression from other column's values.Update Columns by Name
WHERE conditionAn optional clause that, if given, indicates the conditions that rows must satisfy to be updated. condition is an expression that is evaluated for each row. If the expression is true, the row is selected. If there's no WHERE clause, all rows are updated.Update Columns by Name

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:

NameType
startDateINT
amountINT
titleVARCHAR
departmentVARCHAR

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

sql
UPDATE employees
SET department = 'engineering'
WHERE title LIKE '%developer%';

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