简体   繁体   English

如何删除neo4j图数据库

[英]How to delete neo4j graph database

I am opening the database with BatchInserter and I want after the a while to delete the database. 我用BatchInserter打开数据库,我想在一段时间后删除数据库。 I search but I didn't find any drop or clear function. 我搜索,但我没有发现任何下降或清除功能。 What is the proper way to delete the database? 删除数据库的正确方法是什么?

UPDATE: In order to solve my problem at first I close (shutdown) the database and then I am trying to delete the database directory with the following code: 更新:为了解决我的问题,我首先关闭(关闭)数据库,然后我尝试使用以下代码删除数据库目录:

public void deleteRecursively(File file ) {
    if ( !file.exists() ) {
        return;
    }
    if ( file.isDirectory() ) {
        for ( File child : file.listFiles() ) {
            deleteRecursively( child );
        }
    }
    if ( !file.delete() ) {
        throw new RuntimeException( "Couldn't empty database." );
    }
}

But the directory is not always deleted successfully. 但该目录并不总是成功删除。 I think that the problem appears when the database get big. 我认为当数据库变大时会出现问题。 Why is this happening? 为什么会这样?

You can delete the entire directory, or if you want to just delete the contents, you can do 您可以删除整个目录,或者如果您只想删除内容,则可以执行此操作

start n=node(*)
match n-[r?]-()
delete r,n

in 1.9.* 在1.9。*

and in 2.0, I guess the same: 在2.0中,我猜相同:

match n
with n    
optional match n-[r]-()
delete r,n

Refer to luanne's answer and go with manually deleting database directory, say "Database_name.graphdb" (If you want to delete DATABASE) or use this MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r
请参阅luanne的答案并手动删除数据库目录,说“Database_name.graphdb”(如果要删除DATABASE)或使用此MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r

this will delete all your nodes and their relationships (I think, you mean this as your DATABASE). 这将删除所有节点及其关系(我认为,你的意思是你的DATABASE)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM