UPDATE VERTEX¶
UPDATE VERTEX <vid> SET <update_columns>
[WHEN <condition>] [YIELD <columns>]
Use UPDATE VERTEX
to update properties on a vertex. The UPDATE VERTEX
statement only updates one tag of a vertex at a time.
Nebula Graph supports compare-and-set (CAS) operation.
NOTE:
WHEN
andYIELD
are optional.
vid
is the ID of the vertex to be updated.update_columns
is the properties of the vertex to be updated. For example,tag1.col1 = $^.tag2.col2 + 1
means to updatetag1.col1
totag2.col2+1
.NOTE:
$^
indicates the vertex to be updated.
condition
is some constraints. Only when the constraints are met,UPDATE
is executed successfully.condition
supports expression operations.columns
is the columns to be returned.YIELD
returns the latest updated values.
Consider the following example:
nebula> UPDATE VERTEX "player100" \
SET player.age = $^.player.age + 1 \
WHEN $^.player.name == "Tim Duncan" \
YIELD $^.player.name AS name, $^.player.age AS age;
+--------------+-----+
| name | age |
+--------------+-----+
| "Tim Duncan" | 43 |
+--------------+-----+
Last update: March 16, 2021