Skip to main content
Version: 3.10.0

UPDATE EDGE

The UPDATE EDGE statement updates properties on an edge.

In NebulaGraph, UPDATE EDGE supports compare-and-swap (CAS).

Syntax

UPDATE EDGE ON <edge_type>
<src_vid> -> <dst_vid> [@<rank>]
SET <update_prop>
[WHEN <condition>]
[YIELD <output>]
ParameterRequiredDescriptionExample
ON <edge_type>YesSpecifies the edge type. The properties to be updated must be on this edge type.ON serve
<src_vid>YesSpecifies the source vertex ID of the edge."player100"
<dst_vid>YesSpecifies the destination vertex ID of the edge."team204"
<rank>NoSpecifies the rank of the edge. The data type is int.10
SET <update_prop>YesSpecifies the properties to be updated and how they will be updated.SET start_year = start_year +1
WHEN <condition>NoSpecifies the filter conditions. If <condition> evaluates to false, the SET clause does not take effect.WHEN end_year < 2010
YIELD <output>NoSpecifies the output format of the statement.YIELD start_year AS Start_Year

Example

The following example checks the properties of the edge with the GO statement.

nebula> GO FROM "player100" \
OVER serve \
YIELD properties(edge).start_year, properties(edge).end_year;
+-----------------------------+---------------------------+
| properties(EDGE).start_year | properties(EDGE).end_year |
+-----------------------------+---------------------------+
| 1997 | 2016 |
+-----------------------------+---------------------------+

The following example updates the start_year property and returns the end_year and the new start_year.

nebula> UPDATE EDGE on serve "player100" -> "team204"@0 \
SET start_year = start_year + 1 \
WHEN end_year > 2010 \
YIELD start_year, end_year;
+------------+----------+
| start_year | end_year |
+------------+----------+
| 1998 | 2016 |
+------------+----------+