UPDATE EDGE

UPDATE EDGE语句可以修改边上Edge type的属性。

Nebula Graph支持CAS(compare and set)操作。

语法

  1. UPDATE EDGE ON <edge_type>
  2. <src_vid> -> <dst_vid> [@<rank>]
  3. SET <update_prop>
  4. [WHEN <condition>]
  5. [YIELD <output>]
参数是否必须说明示例
ON <edge_type>指定Edge type。要修改的属性必须在这个Edge type内。ON serve
<src_vid>指定边的起始点ID。“player100”
<dst_vid>指定边的目的点ID。“team204”
<rank>指定边的rank值。10
SET <update_prop>指定如何修改属性值。SET start_year = start_year +1
WHEN <condition>指定过滤条件。如果<condition>结果为falseSET子句不会生效。WHEN end_year < 2010
YIELD <output>指定语句的输出格式。YIELD start_year AS Start_Year

示例

  1. // 用GO语句查看边的属性值。
  2. nebula> GO FROM "player100" \
  3. OVER serve \
  4. YIELD serve.start_year, serve.end_year;
  5. +------------------+----------------+
  6. | serve.start_year | serve.end_year |
  7. +------------------+----------------+
  8. | 1997 | 2016 |
  9. +------------------+----------------+
  10. // 修改属性start_year的值,并返回end_year和新的start_year。
  11. nebula> UPDATE EDGE on serve "player100" -> "team204"@0 \
  12. SET start_year = start_year + 1 \
  13. WHEN end_year > 2010 \
  14. YIELD start_year, end_year;
  15. +------------+----------+
  16. | start_year | end_year |
  17. +------------+----------+
  18. | 1998 | 2016 |
  19. +------------+----------+