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 |
---|---|---|
|
The columns to select such as names of columns or the |
|
|
An optional clause that, if given, indicates the conditions that rows must satisfy to be selected. |
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 = '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(BETA)
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.