Update Clauses

Syntax

update_clause ::=
   (SET set_clause ("," (update_clause | set_clause))*) |
   (ADD add_clause ("," (update_clause | add_clause))*) |
   (PUT put_clause ("," (update_clause | put_clause))*) |
   (REMOVE remove_clause ("," remove_clause)*) |
   (JSON MERGE JSON MERGE Clause ("," (update_clause | json_merge_patch_clause))*) |
   (SET TTL ttl_clause ("," update_clause)*)

Semantics

There are six kinds of update clauses:
SET

Updates the value of one or more existing fields. See SET Clause.

ADD

Adds new elements to one or more arrays. See ADD Clause.

PUT

Adds new fields to one or more maps. It can also update the values of existing map fields. See PUT Clause.

REMOVE

Removes elements/fields from one or more arrays/maps. See REMOVE Clause.

JSON MERGE

Updates JSON documents with the changes specified in the patch. See JSON MERGE Clause

SET TTL

Updates the expiration time of the row. See SET TTL Clause.

The update clauses are applied immediately, in the order they appear in the update statement, so the effects of each clause are visible to subsequent clauses. Although the syntax allows for multiple SET TTL clauses, only the last one will be effective; the earlier ones, if any, are ignored.

The SET, ADD, PUT, and REMOVE clauses start with a target expression, which computes the items to be updated or removed. In all cases, the target expression must be either a top-level column reference or a path expression starting with the table alias. If the target expression returns nothing, the update clause is a no-op.