DETACH DELETE removes a node and first deletes every relationship attached to it. Use it when ordinary DELETE cannot remove a connected node. section 3.1.6
Delete Elaine and her relationships
MATCH (n:Person) WHERE n.name = 'Elaine' DETACH DELETE n This query removes the Elaine node together with its attached relationships. section 3.1.6
Use DETACH DELETE when:
- A node still has relationships and ordinary DELETE returns an error. section 3.1.6
- You deliberately want to remove all nodes and relationships by matching every node. section 3.1.6
Listing 3.27 Cypher statement that deletes a single node and all its relationships from the database by using the DETACH DELETE clause
MATCH (n:Person) WHERE n.name = 'Elaine' DETACH DELETE n
Inspect the complete Cypher statement for deleting one node and all its relationships. section 3.1.6
