A newer version of this documentation is available.

View Latest


UPDATE replaces a document that already exists with updated values.


UPDATE keyspace-ref [use-keys-clause] [set-clause] [unset-clause] [where-clause] [limit-clause] [returning-clause]


SET path = expression [update-for] [ , path = expression [update-for] ]*


FOR variable (IN | WITHIN) path  (, variable (IN | WITHIN) path)* [WHEN condition ] END


UNSET path [update-for] (, path [ update-for ])*

keyspace-ref: Specifies the keyspace for which to update the document.

You can add an optional namespace-name to the keyspace-name in this way:


use-keys-clause:Specifies the keys of the data items to be updated. Optional. Keys can be any expression.

set-clause:Specifies the value for an attribute to be changed.

unset-clause: Removes the specified attribute from the document.

update-for: The update for clause uses the FOR statement to iterate over a nested array and SET or UNSET the given attribute for every matching element in the array.

where-clause:Specifies the condition that needs to be met for data to be updated. Optional.

limit-clause:Specifies the greatest number of objects that can be updated. This clause must have a non-negative integer as its upper bound. Optional.

returning-clause:Returns the data you updated as specified in the result_expression.


The following statement changes the "type" of the product, "odwalla-juice1" to "product-juice".

UPDATE product USE KEYS "odwalla-juice1" SET type = "product-juice" RETURNING product.type

"results": [
            "type": "product-juice"

This statement removes the "type" attribute from the "product" keyspace for the document with the "odwalla-juice1" key.

UPDATE product USE KEYS "odwalla-juice1" UNSET type RETURNING product.*

"results": [
            "productId": "odwalla-juice1",
            "unitPrice": 5.4

This statement unsets the "gender" attribute in the "children" array for the document with the key, "dave" in the "tutorial" keyspace.

UPDATE tutorial t USE KEYS "dave" UNSET c.gender FOR c IN children END RETURNING t

"results": [
            "t": {
                "age": 46,
                "children": [
                        "age": 17,
                        "fname": "Aiden"
                        "age": 2,
                        "fname": "Bill"
                "email": "dave@gmail.com",
                "fname": "Dave",
                "hobbies": [
                "lname": "Smith",
                "relation": "friend",
                "title": "Mr.",
                "type": "contact"