Delete databases
Databases can be deleted by using the command DROP DATABASE
.
Note that all database aliases must be dropped before dropping a database.
DROP DATABASE customers
Both standard databases and composite databases can be deleted using this command. |
The DROP DATABASE
command removes a database entirely.
Therefore, it no longer shows up in the listing provided by the command SHOW DATABASES
.
SHOW DATABASES YIELD name
+---------------------+ | name | +---------------------+ | "movies" | | "neo4j" | | "system" | +---------------------+
Use IF EXISTS
when deleting databases
The DROP DATABASE
command is optionally idempotent, with the default behavior to fail with an error if the database does not exist.
Appending IF EXISTS
to the command ensures that no error is returned and nothing happens should the database not exist.
It will always return an error if there is an existing alias that targets the database.
In that case, the alias needs to be dropped before dropping the database.
DROP DATABASE customers IF EXISTS
Use DUMP DATA
or DESTROY DATA
when deleting databases
You can request that a dump of the store files is produced first, and stored in the path configured using the dbms.directories.dumps.root
setting (by default <neo4j-home>/data/dumps
).
This can be achieved by appending DUMP DATA
to the command (or DESTROY DATA
to explicitly request the default behavior).
These dumps are equivalent to those produced by neo4j-admin dump
and can be similarly restored using neo4j-admin load
.
DROP DATABASE movies DUMP DATA
The options IF EXISTS
and DUMP DATA
/ DESTROY DATA
can also be combined.
An example could look like this:
DROP DATABASE customers IF EXISTS DUMP DATA