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
to drop any aliases blocking the deletion of the database
Documenting neo-technology/neo4j#26465, ~~needs
to wait until that has been merged.~~
---------
Co-authored-by: Mark Dixon <[email protected]>
Co-authored-by: Reneta Popova <[email protected]>
Copy file name to clipboardExpand all lines: modules/ROOT/pages/database-administration/composite-databases/delete-composite-databases.adoc
+53-2Lines changed: 53 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,63 @@
3
3
[[composite-databases-delete]]
4
4
= Delete composite databases
5
5
6
-
You can delete composite databases using either the command `DROP COMPOSITE DATABASE name` or the more general one `DROP DATABASE name`.
7
-
However, keep in mind that the first command will fail if the target database is not composite, while the second one will not fail because it targets any database.
6
+
There are two ways of deleting a composite database with constituent database aliases (local or remote) by either dropping the constituent database aliases first and then deleting the composite database, or deleting the composite database while also dropping the constituent database aliases.
7
+
8
+
[[composite-databases-delete-without-aliases]]
9
+
== Delete a composite database
10
+
11
+
Before deleting a composite database, you must ensure that it is not in use by any database aliases.
12
+
If the composite database is in use, you must first drop the aliases that reference it.
13
+
For more information, see xref:database-administration/aliases/manage-aliases-composite-databases.adoc#delete-composite-database-alias[Delete database aliases in composite databases].
14
+
15
+
You can delete composite databases using either the command `DROP COMPOSITE DATABASE name` or the more general one `DROP DATABASE name`.
16
+
However, keep in mind that the first command targets only composite databases, while the second one targets any database.
8
17
9
18
.Query
10
19
[source, cypher]
11
20
----
12
21
DROP COMPOSITE DATABASE inventory
13
22
----
14
23
24
+
[role=label--new-5.24]
25
+
[[composite-databases-delete-with-aliases]]
26
+
== Delete a composite database while dropping its constituents
27
+
28
+
You can use the `CASCADE ALIASES` option of the `DROP COMPOSITE DATABASE` Cypher command to drop the constituent database aliases while deleting the composite database.
29
+
30
+
[NOTE]
31
+
====
32
+
This operation does not deletes the actual target databases of the constituent database aliases.
33
+
====
34
+
35
+
The `CASCADE ALIASES` option is useful when you want to delete a composite database and its constituent database aliases in one step.
36
+
Using `CASCADE ALIASES` requires the `DROP ALIAS` privilege.
37
+
For more information about this privilege, see xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-alias-management[ALIAS MANAGEMENT privileges].
38
+
39
+
.Drop a composite database and its consitutent alias
40
+
====
41
+
This example shows how to create a composite database `movies` and a database alias `movies.sweden` for the database `swedish-movies` and then delete the alias `sweden` and the composite database `movies`.
42
+
43
+
.Create a composite database `movies` and a database alias `movies.sweden` for the database `swedish-movies`
44
+
[source, cypher]
45
+
----
46
+
CREATE COMPOSITE DATABASE movies
47
+
CREATE ALIAS movies.sweden FOR DATABASE `swedish-movies`
48
+
----
49
+
50
+
.Delete the composite database `movies` while also dropping the alias `movies.sweden`
51
+
[source, cypher]
52
+
----
53
+
DROP COMPOSITE DATABASE movies CASCADE ALIASES
54
+
----
55
+
====
56
+
57
+
This behavior is the same for the more general command `DROP DATABASE name` when using it to drop a composite database.
58
+
59
+
//The option `RESTRICT` explicitly requests the default behavior of the command.
60
+
61
+
[NOTE]
62
+
====
63
+
For composite databases, the aliases that are dropped when using the `CASCADE ALIASES` option can be found in the `constituents` column of `SHOW DATABASE`.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/database-administration/standard-databases/delete-databases.adoc
+53-3Lines changed: 53 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Note that all database aliases must be dropped before dropping a database.
17
17
|
18
18
[source, syntax, role="noheader"]
19
19
----
20
-
DROP [COMPOSITE] DATABASE name [IF EXISTS] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SEC[OND[S]]]]\|NOWAIT]
20
+
DROP [COMPOSITE] DATABASE name [IF EXISTS] [RESTRICT \| CASCADE ALIAS[ES]] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SEC[OND[S]]]]\|NOWAIT]
21
21
----
22
22
23
23
|===
@@ -92,9 +92,9 @@ In Neo4j, dumps can be stored in the directory specified by the xref:configurati
92
92
The option `DESTROY DATA` explicitly requests the default behavior of the command.
93
93
94
94
[[delete-existing-db-with-dump]]
95
-
=== Delete a database with `IF{nbsp}EXISTS` and `DUMP DATA`/`DESTROY DATA`
95
+
=== Delete a database with `IF{nbsp}EXISTS` and `DUMP DATA`/`DESTROY DATA`
96
96
97
-
The options `IF EXISTS` and `DUMP DATA`/`DESTROY DATA` can also be combined.
97
+
The options `IF EXISTS` and `DUMP DATA`/`DESTROY DATA` can also be combined.
98
98
99
99
An example could look like this:
100
100
@@ -103,4 +103,54 @@ An example could look like this:
103
103
DROP DATABASE customers IF EXISTS DUMP DATA
104
104
----
105
105
106
+
[[delete-databases-with-aliases]]
107
+
=== Delete a database with local database aliases targeting it
108
+
109
+
There are two ways of dropping a database that is the target of local database aliases:
110
+
111
+
* Drop the local database aliases first, then use `DROP DATABASE name` to drop the database.
112
+
Remote database aliases targeting the database do not affect the deletion of the database and therefore dos not need to be dropped beforehand.
113
+
* Use `DROP DATABASE name CASCADE ALIASES` to also drop the local database aliases targeting it while dropping the database.
114
+
If any of the dropped database aliases are constituents of composite databases, those composite databases will not be dropped.
115
+
This command does not affect the remote database aliases targeting the database being dropped.
116
+
They will simply no longer resolve their targets as if they were created targeting a non-existing database.
117
+
118
+
Using `CASCADE ALIASES` requires the `DROP ALIAS` privilege.
119
+
For more information about the privilege, see xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-alias-management[ALIAS MANAGEMENT privileges].
120
+
121
+
.Drop a database and the local database alias targeting it
122
+
====
123
+
The following example creates a database `movies` and a local database alias `films` targeting it:
124
+
125
+
[source, cypher]
126
+
----
127
+
CREATE DATABASE movies
128
+
CREATE ALIAS films FOR DATABASE movies
129
+
----
130
+
131
+
Then, the database `movies` and the local database alias `films` can be dropped using the following command:
132
+
133
+
[source, cypher]
134
+
----
135
+
DROP DATABASE movies CASCADE ALIASES
136
+
----
137
+
====
138
+
139
+
The option `RESTRICT` explicitly requests the default behavior of the command.
140
+
141
+
[NOTE]
142
+
====
143
+
For standard databases, the aliases that are dropped when using the `CASCADE ALIASES` option can be found in the `aliases` column of `SHOW DATABASE`.
144
+
====
145
+
146
+
[[delete-existing-databases-with-aliases]]
147
+
=== Delete a database with `RESTRICT`/`CASCADE ALIASES` and other command parts
148
+
149
+
The options `RESTRICT`/`CASCADE ALIASES` can also be combined with `IF EXISTS` and `DUMP DATA`/`DESTROY DATA`.
150
+
For example:
151
+
152
+
[source, cypher]
153
+
----
154
+
DROP DATABASE movies IF EXISTS CASCADE ALIASES DUMP DATA
0 commit comments