概述
delete()
子句删除图集中符合过滤条件的点、边。要特别注意,删除一个点时,与该点连接的所有边也会被删除。
删除操作不可逆。
语法
// 删除点
delete().nodes(<filter>).limit(<N>)
// 删除边
delete().edges(<filter>).limit(<N>)
- 符合
nodes()
或edges()
方法中指定条件的点或边才会被删除。过滤条件为空时,删除全部点、边。 - 在
limit()
方法(可选)中限制要删除的数据量。 - 不支持定义子句别名。
示例图集

在一个空图集中,逐行运行以下UQL语句,创建示例图集:
create().node_schema("user").edge_schema("follow")
create().node_property(@user, "name").node_property(@user, "age", int32).edge_property(@follow, "time", datetime)
insert().into(@user).nodes([{_id:"U001", _uuid:1, name:"Jason", age:30}, {_id:"U002", _uuid:2, name:"Tim"}, {_id:"U003", _uuid:3, name:"Grace", age:25}, {_id:"U004", _uuid:4, name:"Ted", age:26}])
insert().into(@follow).edges([{_uuid:1, _from_uuid:4, _to_uuid:1, time:"2021-9-10"}, {_uuid:2, _from_uuid:3, _to_uuid:2, time:"2020-3-12"}, {_uuid:3, _from_uuid:4, _to_uuid:2, time:"2023-7-30"}])
示例
删除点
delete().nodes({name == "Grace"})
本例删除了_id
为U003的点,以及与之相连的_uuid
为2的边。
删除边
delete().edges({@follow})
本例删除所有@follow边。
限制删除数量
delete().nodes({@user.age > 26}).limit(2)
本例删除age
属性大于26的@user
点,且仅删除最先找到的两个点。