Removes vertices from the database. This is the equivalent of the
DELETE command, with the addition of checking and maintaining consistency with edges, removing all cross-references to the deleted vertex in all edges involved.
DELETE VERTEX <vertex> [WHERE <conditions>] [LIMIT <MaxRecords>>] [BATCH <batch-size>]
<vertex>Defines the vertex that you want to remove, using its Class, Record ID, or through a sub-query using the
WHEREFilter condition to determine which records the command removes.
LIMITDefines the maximum number of records to remove.
BATCHDefines how many records the command removes at a time, allowing you to break large transactions into smaller blocks to save on memory usage. By default, it operates on blocks of 100.
Remove the vertex and disconnect all vertices that point towards it:
DELETE VERTEX #10:231
Remove all user accounts marked with an incoming edge on the class
DELETE VERTEX Account WHERE in.@Class CONTAINS 'BadBehaviorInForum'
Remove all vertices from the class
EmailMessagesmarked with the property
DELETE VERTEX EMailMessage WHERE isSpam = TRUE
Remove vertices of the class
Attachment, where the vertex has an edge of the class
HasAttachmentwhere the property
dateis set before 1990 and the vertex
Attachmentwith the condition that its property
fromis set to
DELETE VERTEX Attachment WHERE in[@Class = 'HasAttachment'].date <= "1990" AND in.out[@Class = "Email"].from = 'some...@example.com'
Remove vertices in blocks of one thousand:
DELETE VERTEX v BATCH 1000
This feature was introduced in version 2.1.
In the case you want to delete one or more classes of vertices and all the connected edges resides only on particular classes, you could use the
TRUNCATE CLASS command against both vertex and edge classes by specifying the
TRUNCATE CLASS is much faster than
DELETE VERTEX, because it doesn't take in consideration the removal of the edges. Use
TRUNCATE CLASS only when you are certain that there will not be broken edges on other vertices instances. Example of deleting all the instances of vertices classes
Attachment and the edge class that connect them
TRUNCATE CLASS Email UNSAFEorientdb>
TRUNCATE CLASS HasAttachment UNSAFEorientdb>
TRUNCATE CLASS Attachment UNSAFE
- Introduces the optional
BATCHclause for managing batch size on the operation.
- Command begins using the Blueprints API. When working in Java using the OGraphDatabase API, you may experience differences in how the database manages edges. To force the command to work with the older API, change the Graph DB settings using
- Initial version.