Skip to content

UPDATE VERTEX

The UPDATE VERTEX statement updates properties on tags of a vertex.

In NebulaGraph, 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>]
Parameter 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 will not take effect. WHEN name == "Tim"
YIELD <output> No Specifies the output format of the statement. YIELD name AS Name

Example

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

// This query updates the age property and returns 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: March 13, 2023