Skip to content

UPDATE EDGE

The UPDATE EDGE statement updates properties on an edge.

In Nebula Graph, 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>]
Parameter Required Description Example
ON <edge_type> Yes Specifies the edge type. The properties to be updated must be on this edge type. ON serve
<src_vid> Yes Specifies the source vertex ID of the edge. "player100"
<dst_vid> Yes Specifies the destination vertex ID of the edge. "team204"
<rank> No Specifies the rank of the edge. 10
SET <update_prop> Yes Specifies the properties to be updated and how they will be updated. SET start_year = start_year +1
WHEN <condition> No Specifies the filter conditions. If <condition> evaluates to false, the SET clause does not take effect. WHEN end_year < 2010
YIELD <output> No Specifies 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;
+------------------+----------------+
| serve.start_year | serve.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     |
+------------+----------+

Last update: November 24, 2021
Back to top