SQL - DELETE VERTEX
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.
Syntax
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 theFROM (<sub-query)
clause.WHERE
Filter condition to determine which records the command removes.LIMIT
Defines the maximum number of records to remove.BATCH
Defines 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.
Example
Remove the vertex and disconnect all vertices that point towards it:
- orientdb>
DELETE VERTEX #10:231
- orientdb>
Remove all user accounts marked with an incoming edge on the class
BadBehaviorInForum
:- orientdb>
DELETE VERTEX Account WHERE in.@Class CONTAINS
'BadBehaviorInForum'
- orientdb>
Remove all vertices from the class
EmailMessages
marked with the propertyisSpam
:- orientdb>
DELETE VERTEX EMailMessage WHERE isSpam = TRUE
- orientdb>
Remove vertices of the class
Attachment
, where the vertex has an edge of the classHasAttachment
where the propertydate
is set before 1990 and the vertexEmail
connected to classAttachment
with the condition that its propertyfrom
is set tobob@example.com
:- orientdb>
DELETE VERTEX Attachment WHERE in[@Class = 'HasAttachment'].date
<= "1990" AND in.out[@Class = "Email"].from = 'some...@example.com'
- orientdb>
Remove vertices in blocks of one thousand:
- orientdb>
DELETE VERTEX v BATCH 1000
This feature was introduced in version 2.1.
- orientdb>
History
Version 2.1
- Introduces the optional
BATCH
clause for managing batch size on the operation.
Version 1.4
- 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
ALTER DATABASE
.
Version 1.1
- Initial version.