Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete all nodes and relationships in neo4j 1.8

I know this question is asked by many people already
for my research, here's some questions asked before

  1. How to delete all relationships in neo4j graph?
  2. https://groups.google.com/forum/#!topic/neo4j/lgIaESPgUgE

But after all, still can't solve our problems,
we just want to delete "ALL" nodes and "ALL" relationships

enter image description here

suppose delete "ALL" can see there are left 0 nodes 0 properties and 0 relationships

This is the screenshot i took after executing the delete "ALL" suggested by forum

My question still the same, how do delete all nodes and all relationships in neo4j

like image 783
Huei Tan Avatar asked Jan 10 '13 07:01

Huei Tan


People also ask

How do I delete all relationships in Neo4j?

Deleting relationship is as simple as deleting nodes. Use the MATCH statement to match the relationships you want to delete. You can delete one or many relationships or all relationships by using one statement.

How do I delete a node in Neo4j?

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.


1 Answers

As of 2.3.0 and up to 3.3.0

MATCH (n) DETACH DELETE n 

Docs

Pre 2.3.0

MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r 

Docs

like image 65
Bob B Avatar answered Sep 18 '22 15:09

Bob B