Skip to content

Commit

Permalink
Update the page on how to delete db (#1777) (#1779)
Browse files Browse the repository at this point in the history
Fix the following: 

- the config - `dbms.directories.dumps.root` →
`server.directories.dumps.root`
- `neo4j-admin dump` command → `neo4j-admin database dump`
- `neo4j-admin load` command → `neo4j-admin database load`
  • Loading branch information
NataliaIvakina authored Aug 20, 2024
1 parent 4408f36 commit 4e3d955
Showing 1 changed file with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ DROP [COMPOSITE] DATABASE name [IF EXISTS] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SE

|===

== Usage examples
== Examples

[[delete-database]]
=== Delete a database

To delete the database `customers`, run the following command:

.Delete a database
======
.Query
[source, cypher]
----
DROP DATABASE customers
Expand All @@ -38,9 +40,8 @@ Both standard databases and composite databases can be deleted using this comman
====

The `DROP DATABASE` command removes a database entirely.
Therefore, it no longer shows up in the listing provided by the command `SHOW DATABASES`.
Therefore, it no longer shows up in the listing provided by the command `SHOW DATABASES`:

.Query
[source, cypher]
----
SHOW DATABASES YIELD name
Expand All @@ -57,54 +58,49 @@ SHOW DATABASES YIELD name
| "system" |
+---------------------+
----
======


[[delete-databases-existing]]
=== Use `IF EXISTS` when deleting databases
=== Delete a database with `IF{nbsp}EXISTS`

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.

Appending `IF EXISTS` to the command ensures that no error is returned and nothing happens if the database does not exist.

It always returns 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.

.Query
[source, cypher]
----
DROP DATABASE customers IF EXISTS
----

[[manage-databases-dump]]
=== 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`.
=== Delete a database with `DUMP DATA` or `DESTROY DATA`

////
[source, cypher, role=test-setup]
----
DROP ALIAS `films` FOR DATABASE;
DROP ALIAS `motion pictures` FOR DATABASE;
----
////
By appending `DUMP DATA` to the command `DROP DATABASE`, you can create a dump of the store files before deleting the database:

.Query
[source, cypher]
----
DROP DATABASE movies DUMP DATA
----

These dumps are equivalent to those produced by xref:backup-restore/offline-backup.adoc[`neo4j-admin database dump`] and can be similarly restored using the xref:backup-restore/restore-dump.adoc[`neo4j-admin database load`] command.

In Neo4j, dumps can be stored in the directory specified by the xref:configuration/configuration-settings.adoc#config_server.directories.dumps.root[`server.directories.dumps.root`] setting (by default, the path for storing dumps is xref:configuration/file-locations.adoc#data[`<neo4j-home>/data/dumps`]).

The option `DESTROY DATA` explicitly requests the default behavior of the command.

[[delete-existing-db-with-dump]]
=== Delete a database with `IF{nbsp}EXISTS` and `DUMP DATA`/ `DESTROY DATA`

The options `IF EXISTS` and `DUMP DATA`/ `DESTROY DATA` can also be combined.

.Combine `IF EXISTS` and `DUMP DATA`/ `DESTROY DATA`
======
The options `IF EXISTS` and `DUMP DATA`/ `DESTROY DATA` can also be combined.
An example could look like this:

.Query
[source, cypher]
----
DROP DATABASE customers IF EXISTS DUMP DATA
----
======


0 comments on commit 4e3d955

Please sign in to comment.