neo4j
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
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?
Similar Posts
- Get all nodes with same label using label name Cypher query neo4j
- Get all related nodes of a node using Cypher query neo4j
- Get nodes using multiple ids Cypher query neo4j
- Get all nodes cypher query neo4j
- Create one or multiple nodes Cypher query neo4j
- Sort nodes in descending order Cypher query neo4j
- Sort nodes by id ascending and descending order neo4j Cypher query