Skip to content

UPDATE VERTEX

The UPDATE VERTEX statement updates properties on a vertex. UPDATE VERTEX supports compare-and-set (CAS).

Note

An UPDATE VERTEX statement can only update properties on ONE TAG of a vertex.

Syntax

UPDATE VERTEX ON <tag_name> <vid>
SET <update_prop>
[WHEN <condition>]
[YIELD <output>]
Field Required Description Example
ON <tag_name> Yes Specifies the tag of the vertex. The properties to be updated must be on this tag. ON player
<vid> Yes Specifies the ID of the vertex to be updated. "player100"
SET <update_prop> Yes Specifies the properties to be updated and how they will be updated. SET age = age +1
WHEN <condition> No Specifies the filter conditions. If <condition> evaluates to false, the SET clause does not take effect. WHEN name == "Tim"
YIELD <output> No Specifies the output format of the statement. YIELD name AS Name

Example

// Check the properties of vertex "player101".
nebula> FETCH PROP ON player "player101";
+-----------------------------------------------------+
| vertices_                                           |
+-----------------------------------------------------+
| ("player101" :player{age: 36, name: "Tony Parker"}) |
+-----------------------------------------------------+

// Update the age property and return name and the new age.
nebula> UPDATE VERTEX ON player "player101" \
        SET age = age + 2 \
        WHEN name == "Tony Parker" \
        YIELD name AS Name, age AS Age;
+---------------+-----+
| Name          | Age |
+---------------+-----+
| "Tony Parker" | 38  |
+---------------+-----+

Last update: May 7, 2021
Back to top