How to reset / clear / delete neo4j database?

╄→尐↘猪︶ㄣ 提交于 2019-12-17 09:16:09

问题


We can delete all nodes and relationships by following query.

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

But newly created node get internal id as ({last node internal id} + 1) . It doesn't reset to zero.

How can we reset neo4j database such as newly created node will get id as 0?

From 2.3, we can delete all nodes with relationships,

MATCH (n)
DETACH DELETE n

回答1:


Shut down your Neo4j server, do a rm -rf data/graph.db and start up the server again. This procedure completely wipes your data, so handle with care.




回答2:


If you are using it on a docker container, you can do

docker-compose rm -f -s -v myNeo4jService




回答3:


Since neo4j only runs current database specified in the conf file, an easy way to start a new and clean db is to change the current database in the neo4j.conf file and then restart neo4j server.

dbms.active_database=graph.db --> dbms.active_database=graph2.db

Some might argue that the database name is changed. But as of this writing [2018-12], neo4j doesn't support multiple database instances. There is no need for us to differentiate between databases, thus the name of the database is not used in our code.



来源:https://stackoverflow.com/questions/23310114/how-to-reset-clear-delete-neo4j-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!