SQL - DELETE
Removes one or more records from the database. You can refine the set of records that it removes using the WHERE clause.
NOTE: Don't use
DELETEto remove Vertices or Edges. Instead use theDELETE VERTEXorDELETE EDGEcommands, which ensures the integrity of the graph. If you must carry out aDELETEyou can use theUNSAFEkeyword to do so. However, if you do, you'll end up with orphaned edge pointers, which you'll have to manually clean up.
Syntax:
DELETE FROM <Class>|CLUSTER:<cluster>|INDEX:<index> [LOCK <default|record>] [RETURN <returning>]
[WHERE <Condition>*] [LIMIT <MaxRecords>] [TIMEOUT <timeout>]
LOCKDetermines how the database locks the record between load and delete. It takes one of the following values:DEFAULTDefines no locks during the delete. In the case of concurrent deletes, the MVCC throws an exception.RECORDDefines record locks during the delete.
RETURNDefines what values the database returns. It takes one of the following values:COUNTReturns the number of deleted records. This is the default option.BEFOREReturns the number of records before the removal.
WHEREFilters to the records you want to delete.LIMITDefines the maximum number of records to delete.TIMEOUTDefines the time period to allow the operation to run, before it times out.UNSAFEAllows for the processing of a DELETE on a Vertex or an Edge, without an exception error. It is not recommended to use this! If you must delete an Edge or a Vertex, use the corresponding commands DELETE EDGE or DELETE VERTEX.
Examples:
-
Delete all recods with the surname
unknown, ignoring case:orientdb>
DELETE FROM Profile WHERE surname.toLowerCase() = 'unknown'
For more information, see SQL Commands.