Search code snippets, questions, articles... Chrome Extension

Delete nodes using Cypher query neo4j

To delete single or multiple nodes using Cypher query in neo4j graph database, the DELETE clause can be used.
MATCH (n:Movie {name: 'Matrix'})
DELETE n
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

In the above Cypher query, we are deleting a node that has the label Movie and its name property contains value Matrix. The query will delete the node from the database.

MATCH (n)
DETACH DELETE n
The above Cypher query will delete all nodes from the graph database. Use the query very carefully because it will delete all nodes along with their properties.
MATCH (n:Person {name: 'John Deo'})
DETACH DELETE n
The Cypher query can be used to delete nodes along with all their relationships with other nodes. We use DETACH DELETE clause to delete node with its relationship to other nodes.
MATCH (n:Movie {name: 'Matrix'})-[r:KNOWS]->()
DELETE r
The above Cypher query will delete the relationships of a node with a Movie label and name property value as Matrix with all other nodes.
Was this helpful?
0 Comments
Join Devsheet Ask a Question