OrientDB - Delete Edge


Advertisements


Delete edge command is used to remove the database. This is equivalent of the delete command, with the addition of checking and maintaining consistency with vertices by removing all cross-references to the edge from both ‘in’ and ‘out’ vertex properties.

The following statement is the basic syntax of Delete Edge command.

DELETE EDGE  
   ( <rid> 
      | 
      [<rid> (, <rid>)*] 
      | 
      ( [ FROM (<rid> | <select_statement> ) ] [ TO ( <rid> | <select_statement> ) ] ) 
      | 
      [<class>]  
   ( 
      [WHERE <conditions>] 
      [LIMIT <MaxRecords>]  
      [BATCH <batch-size>]
   ))
   

Following are the details about the options in the above syntax.

FROM − Defines the starting point vertex of the edge to delete.

To − Defines the ending point vertex of the edge to delete.

WHERE − Defines the filtering conditions.

LIMIT − Defines the maximum number of edges to delete.

BATCH − Defines the block size for the operation.

Example

Try the following examples to learn how to delete edges.

Execute the following query to delete the edge between two vertices (#11:2, #11:10). But there might be a chance that might exist one or more edges between two vertices. So that we are using the date property for proper functionality. This query will delete the edges which are created on '2015-01-15' and later.

orientdb {db = demo}> DELETE EDGE FROM #11:2 TO #11:10 WHERE date >= "2012-01-15" 

If the above query is executed successfully, you will get the following output.

Delete record(s) '2' in 0.00200 sec(s)

Execute the following query to delete edges starting from the vertex ‘#11:5’ to the vertex ‘#11:10’ and which are related to ‘class = Customer’.

orientdb {db = demo}> DELETE EDGE FROM #11:5 TO #11:10 WHERE @class = 'Customer' 

If the above query is executed successfully, you will get the following output.

Delete record(s) '2' in 0.00200 sec(s)


Advertisements
E-Books Store