Reputation: 1089
I am opening the database with BatchInserter and I want after the a while to delete the database. 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?
Upvotes: 2
Views: 2938
Reputation: 167
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
this will delete all your nodes and their relationships (I think, you mean this as your DATABASE).
Upvotes: 1
Reputation: 19373
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.*
and in 2.0, I guess the same:
match n
with n
optional match n-[r]-()
delete r,n
Upvotes: 7