Remove one or more records from the database. You can determine which records get deleted using the WHERE
clause.
Syntax
DELETE FROM <target-name> [LOCK <lock-type>] [RETURN <return-type>]
[WHERE <condition>*] [LIMIT <MaxRecords>] [TIMEOUT <timeout-value>]
<target-name>
Defines the target from which you want to delete records. Use one of the following target names:<class-name>
Determines what class you want to delete from.CLUSTER:<cluster-name>
Determines what cluster you want to delete from.INDEX:<index-name>
Determines what index you want to delete from.
LOCK <lock-type>
Defines how the record locks between the load and deletion. It takes one of two types:DEFAULT
Operation uses no locks. In the event of concurrent deletions, the MVCC throws an exception.RECORD
Locks the record during the deletion.
RETURN <return-type>
Defines what the Console returns. There are two supported return types:COUNT
Returns the number of deleted records. This is the default return type.BEFORE
Returns the records before the deletion.
WHERE <condition>
Defines the condition used in selecting records for deletion.LIMIT
Defines the maximum number of records to delete.TIMEOUT
Defines the time-limit to allow the operation to run before it times out.
NOTE: When dealing with vertices and edges, do not use the standard SQL
DELETE
command. Doing so can disrupt graph integrity. Instead, use theDELETE VERTEX
or theDELETE EDGE
commands.
Examples
-
Remove all records from the class
Profile
, where the surname is unknown, ignoring case:orientdb>
DELETE FROM Profile WHERE surname.toLowerCase() = 'unknown'
For more information on other commands, see SQL Commands and Console Commands.