Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DETACH DELETE Neo4j 2.3.x/Cypher

Tags:

neo4j

cypher

What is the behaviour and purpose of the new Cypher operator DETACH DELETE added in Neo4j 2.3.x?

like image 341
alexanoid Avatar asked Oct 15 '15 04:10

alexanoid


People also ask

How do I remove a property from neo4j?

Remove all properties REMOVE cannot be used to remove all existing properties from a node or relationship. Instead, using SET with = and an empty map as the right operand will clear all properties from the node or relationship.

How do I delete a Cypher?

To delete nodes and relationships using Cypher, use the DELETE clause. The DELETE clause is used within the MATCH statement to delete whatever data was matched. So, the DELETE clause is used in the same place we used the RETURN clause in our previous examples.

How do I delete a particular relationship in neo4j?

Deleting relationship is as simple as deleting nodes. Use the MATCH statement to match the relationships you want to delete. You can delete one or many relationships or all relationships by using one statement.


1 Answers

If you want to delete nodes, you need to delete the relationships as well. In previous versions you would need to do:

MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n, r

Now you can simply say:

MATCH (n)
DETACH DELETE n
like image 154
Brian Underwood Avatar answered Sep 18 '22 18:09

Brian Underwood