How to delete neo4j graph database

java, neo4j

Solution

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

Problem

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?

Original source