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. 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.
UPDATE table_name [ [ AS ] alias ]
SET { column_name = expression } [, ...]
[ WHERE condition ]
Parameters
The UPDATE
statement accepts the following required parameters.
Parameter | Description | Example |
---|---|---|
|
The name of column to set value for. |
|
|
The value to assign. Can be a literal, parameter, or an expression from other column’s values. |
|
|
An optional clause that, if given, indicates the conditions that rows must satisfy to be updated. |
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 |
|
|
|
|
|
|
|
|
You can update the values of the Employee.department
field:
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:
-
For Java objects (
Serializable
,DataSerializable
,IdentifiedDataSerializable
), you must add the object’s class to the classpath of the member you are sending the query to. -
For
Portable
/Compact
objects, you do not need to add the object’s class to the classpath of the member, unless you want to use parameterized queries to compare one object against another.