我知道这个问题已经被很多人问过了 为了我的研究,这里有一些以前提出的问题
但毕竟,还是不能解决我们的问题, 我们只想删除“所有”节点和“所有”关系
假设删除“所有”可以看到有留下的 0节点0属性和0关系
这是我在执行论坛建议的删除“所有”后截图
我的问题仍然是相同的,如何删除所有节点和所有关系在 neo4j
you are probably doing it correct, only the dashboard shows just the higher ID taken, and thus the number of "active" nodes, relationships, although there are none. it is just informative.
to be sure you have an empty graph, run this command:
START n=node(*) return count(n); START r=rel(*) return count(r);
if both give you 0, your deletion was succesfull.
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
It will do the trick..
Match (n)-[r]-() Delete n,r;
for a big database you should either remove the database from the disk (after you stop the engine first I guess) or use in Cypher something like:
MATCH (n) OPTIONAL MATCH (n)-[r]-() WITH n,r LIMIT 50000 DELETE n,r RETURN count(n) as deletedNodesCount
see https://zoomicon.wordpress.com/2015/04/18/howto-delete-all-nodes-and-relationships-from-neo4j-graph-database/ for some more info I've gathered on this from various answers
Neo4j cannot delete nodes that have a relation. You have to delete the relations before you can delete the nodes.
But, it is simple way to delete "ALL" nodes and "ALL" relationships with a simple chyper. This is the code:
--> DETACH DELETE will remove all of the nodes and relations by Match
if the name of node is for example : abcd then below query will work :
MATCH (n:abcd) DETACH DELETE n
This will only delete the node with label "abcd" and all its relation-ships.
Probably you will want to delete Constraints and Indexes