You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/ROOT/pages/database-administration/standard-databases/delete-databases.adoc
+25-29Lines changed: 25 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,11 +22,13 @@ DROP [COMPOSITE] DATABASE name [IF EXISTS] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SE
22
22
23
23
|===
24
24
25
-
== Usage examples
25
+
== Examples
26
+
27
+
[[delete-database]]
28
+
=== Delete a database
29
+
30
+
To delete the database `customers`, run the following command:
26
31
27
-
.Delete a database
28
-
======
29
-
.Query
30
32
[source, cypher]
31
33
----
32
34
DROP DATABASE customers
@@ -38,9 +40,8 @@ Both standard databases and composite databases can be deleted using this comman
38
40
====
39
41
40
42
The `DROP DATABASE` command removes a database entirely.
41
-
Therefore, it no longer shows up in the listing provided by the command `SHOW DATABASES`.
43
+
Therefore, it no longer shows up in the listing provided by the command `SHOW DATABASES`:
42
44
43
-
.Query
44
45
[source, cypher]
45
46
----
46
47
SHOW DATABASES YIELD name
@@ -57,54 +58,49 @@ SHOW DATABASES YIELD name
57
58
| "system" |
58
59
+---------------------+
59
60
----
60
-
======
61
+
61
62
62
63
[[delete-databases-existing]]
63
-
=== Use `IFEXISTS` when deleting databases
64
+
=== Delete a database with `IF{nbsp}EXISTS`
64
65
65
66
The `DROP DATABASE` command is optionally idempotent, with the default behavior to fail with an error if the database does not exist.
66
-
Appending `IF EXISTS` to the command ensures that no error is returned and nothing happens should the database not exist.
67
-
It will always return an error if there is an existing alias that targets the database.
67
+
68
+
Appending `IF EXISTS` to the command ensures that no error is returned and nothing happens if the database does not exist.
69
+
70
+
It always returns an error if there is an existing alias that targets the database.
68
71
In that case, the alias needs to be dropped before dropping the database.
69
72
70
-
.Query
71
73
[source, cypher]
72
74
----
73
75
DROP DATABASE customers IF EXISTS
74
76
----
75
77
76
78
[[manage-databases-dump]]
77
-
=== Use `DUMP DATA` or `DESTROY DATA` when deleting databases
78
-
79
-
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`).
80
-
This can be achieved by appending `DUMP DATA` to the command (or `DESTROY DATA` to explicitly request the default behavior).
81
-
These dumps are equivalent to those produced by `neo4j-admin dump` and can be similarly restored using `neo4j-admin load`.
79
+
=== Delete a database with `DUMP DATA` or `DESTROY DATA`
82
80
83
-
////
84
-
[source, cypher, role=test-setup]
85
-
----
86
-
DROP ALIAS `films` FOR DATABASE;
87
-
DROP ALIAS `motion pictures` FOR DATABASE;
88
-
----
89
-
////
81
+
By appending `DUMP DATA` to the command `DROP DATABASE`, you can create a dump of the store files before deleting the database:
90
82
91
-
.Query
92
83
[source, cypher]
93
84
----
94
85
DROP DATABASE movies DUMP DATA
95
86
----
96
87
88
+
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.
89
+
90
+
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`]).
91
+
92
+
The option `DESTROY DATA` explicitly requests the default behavior of the command.
93
+
94
+
[[delete-existing-db-with-dump]]
95
+
=== Delete a database with `IF{nbsp}EXISTS` and `DUMP DATA`/ `DESTROY DATA`
96
+
97
+
The options `IF EXISTS` and `DUMP DATA`/ `DESTROY DATA` can also be combined.
97
98
98
-
.Combine `IF EXISTS` and `DUMP DATA`/ `DESTROY DATA`
99
-
======
100
-
The options `IF EXISTS` and `DUMP DATA`/ `DESTROY DATA` can also be combined.
0 commit comments