Neo4j Delete a Node
In Neo4j, DELETE statement is always used with MATCH statement to delete whatever data is matched. The DELETE command is used in the same place we used the RETURN clause in our previous examples.
Delete Multiple Nodes
You can delete multiple nodes by using MATCH and DELETE commands in a single statement. You just have to put the different nodes separated by a column.
Suppose you have these two nodes:
Use the following command to delete the both nodes.
You can see the above displayed message that both nodes have been deleted.
Delete All Nodes
To delete all nodes from the database, don?t use any filter criteria.
Note: The above statement cannot delete nodes if they have any relationships. In other words, you must delete any relationships before you delete the node itself. Otherwise you will get the following error message.
There is a method to delete a node and all relationships related to that node.
Use the DETACH DELETE statement:
This will delete the node "Kohli" where name is "Virat Kohli" with all its relationship.