Skip to main content
Version: 3.11.0

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>]
ParameterRequiredDescriptionExample
ON <tag_name>YesSpecifies the tag of the vertex. The properties to be updated must be on this tag.ON player
<vid>YesSpecifies the ID of the vertex to be updated."player100"
SET <update_prop>YesSpecifies the properties to be updated and how they will be updated.SET age = age +1
WHEN <condition>NoSpecifies the filter conditions. If <condition> evaluates to false, the SET clause will not take effect.WHEN name == "Tim"
YIELD <output>NoSpecifies 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" YIELD properties(vertex);
+--------------------------------+
| properties(VERTEX) |
+--------------------------------+
| {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 |
+---------------+-----+