Neo4j Delete Node
In Neo4j to delete a node or relations between nodes you have to use DELETE clause. To delete any node you need DELETE clause with the MATCH statement, the MATCH statement data will find the specific node and whichever node is matched with the statement that node will be vanished. Similar to the CREATE and RETURN statement just it will replace the CREATE with MATCH and RETURN with the DELETE. Below examples will illustrate the approach.
Example: The basic way to delete a node is to find the node and delete the match node, but before you can check the node is that the node you want to delete by using RETURN statement after that you can fire below query. This query will delete the node where label is “GeeksforGeeks” Tag is “A Computer Science Portal” and the type is “Edutech”.
$ MATCH (a:GeksforGeeks { Tag : "A Computer Science Portal", Type : "Edutech" })
DELETE a
Output:
Deleting multiple nodes:
To delete multiple nodes use the DELETE statement and separate the nodes by “, ” coma or you can use multiple time MATCH statement Like the below query.
$ DELETE (a:GeeksforGeeks { Tag: "A Computer Science Portal"}),
(b:W3School { Tag: "We are the Learner"})
MATCH a, b
or
$ MATCH (a:GeeksforGeeks { Tag: "A Computer Science Portal"})
MATCH (b:W3School { Tag: "We are the Learner"})
DELETE a, b
Output:
Delete all nodes: To delete all the nodes at once is to much short query to fire the below query will delete all the nodes at once.
$ MATCH (n) DELETE n
Output:

Note: To delete any node or nodes that containing relationship with other nodes will display an error message.
Recommended Posts:
- Delete Operation in B-Tree
- SQL | DELETE Statement
- Neo4j Drop Index
- Difference between DELETE and DROP in SQL
- Neo4j Introduction
- Neo4j Installation
- Neo4j Create Index
- Neo4j Create Node
- Neo4j Create Relationship
- Neo4j Create Constraint
- Neo4j Query Cypher Language
- Neo4j | Naming rules and recommendations
- Neo4j | Values and Types
- Altering a table to add a collection data type in Cassandra
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

