DELETE VERTEX¶
By default, the DELETE VERTEX statement deletes vertices but the incoming and outgoing edges of the vertices.
Compatibility
- NebulaGraph 2.x deletes vertices and their incoming and outgoing edges.
- NebulaGraph 3.1.3 only deletes the vertices, and does not delete the related outgoing and incoming edges of the vertices. At this time, there will be dangling edges by default.
The DELETE VERTEX statement deletes one vertex or multiple vertices at a time. You can use DELETE VERTEX together with pipes. For more information about pipe, see Pipe operator.
Note
DELETE VERTEXdeletes vertices directly.
DELETE TAGdeletes a tag with the given name on a specified vertex.
Syntax¶
DELETE VERTEX <vid> [, <vid> ...] [WITH EDGE];
- WITH EDGE: deletes vertices and the related incoming and outgoing edges of the vertices.
Examples¶
This query deletes the vertex whose ID is "team1".
# Delete the vertex whose VID is `team1` but the related incoming and outgoing edges are not deleted.
nebula> DELETE VERTEX "team1";
# Delete the vertex whose VID is `team1` and the related incoming and outgoing edges.
nebula> DELETE VERTEX "team1" WITH EDGE;
This query shows that you can use DELETE VERTEX together with pipe to delete vertices.
nebula> GO FROM "player100" OVER serve WHERE properties(edge).start_year == "2021" YIELD dst(edge) AS id | DELETE VERTEX $-.id;
Process of deleting vertices¶
Once NebulaGraph deletes the vertices, all edges (incoming and outgoing edges) of the target vertex will become dangling edges. When NebulaGraph deletes the vertices WITH EDGE, NebulaGraph traverses the incoming and outgoing edges related to the vertices and deletes them all. Then NebulaGraph deletes the vertices.
Caution
- Atomic deletion is not supported during the entire process for now. Please retry when a failure occurs to avoid partial deletion, which will cause pendent edges.
- Deleting a supernode takes a lot of time. To avoid connection timeout before the deletion is complete, you can modify the parameter
--storage_client_timeout_msinnebula-graphd.confto extend the timeout period.