Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
488a86d
Add `DROP DATABASE name CASCADE ALIASES`
Hunterness Sep 3, 2024
5b7e27e
Add sentences about additional privileges
Hunterness Sep 4, 2024
994f3b9
Apply suggestions from code review
Hunterness Sep 4, 2024
41be4e4
Address review comments
Hunterness Sep 5, 2024
821a506
Address review comments
Hunterness Sep 19, 2024
6b05ee1
update examples slightly
Hunterness Sep 20, 2024
767b535
Update modules/ROOT/pages/database-administration/standard-databases/…
renetapopova Sep 24, 2024
32a35f9
Update modules/ROOT/pages/database-administration/standard-databases/…
renetapopova Sep 24, 2024
2c5af59
Update modules/ROOT/pages/database-administration/composite-databases…
renetapopova Sep 24, 2024
4023823
Update modules/ROOT/pages/database-administration/composite-databases…
renetapopova Sep 24, 2024
c42b313
Update modules/ROOT/pages/database-administration/standard-databases/…
renetapopova Sep 24, 2024
99ed2bc
editial update of delete composite database page
renetapopova Sep 24, 2024
8ed9ecd
Update modules/ROOT/pages/database-administration/composite-databases…
renetapopova Sep 24, 2024
c670df8
Update modules/ROOT/pages/database-administration/standard-databases/…
renetapopova Sep 24, 2024
a2e6614
Update modules/ROOT/pages/database-administration/standard-databases/…
renetapopova Sep 24, 2024
1afc7d8
fix the example and the label
renetapopova Sep 24, 2024
41a79e8
remove we
renetapopova Sep 24, 2024
b714145
Update modules/ROOT/pages/database-administration/standard-databases/…
renetapopova Sep 24, 2024
31d1e6b
Update modules/ROOT/pages/database-administration/composite-databases…
renetapopova Sep 24, 2024
5b88e8c
Update modules/ROOT/pages/database-administration/standard-databases/…
renetapopova Sep 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ SHOW ALIASES FOR DATABASE YIELD *
+-----------------------------------------------------------------------------------------------------------------------------------+
----

[[delete-composite-database-alias]]
== Delete database aliases in composite databases

To delete an alias in a composite database, use the `DROP ALIAS FOR DATABASE` command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,63 @@
[[composite-databases-delete]]
= Delete composite databases

You can delete composite databases using either the command `DROP COMPOSITE DATABASE name` or the more general one `DROP DATABASE name`.
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.
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.

[[composite-databases-delete-without-aliases]]
== Delete a composite database

Before deleting a composite database, you must ensure that it is not in use by any database aliases.
If the composite database is in use, you must first drop the aliases that reference it.
For more information, see xref:database-administration/aliases/manage-aliases-composite-databases.adoc#delete-composite-database-alias[Delete database aliases in composite databases].

You can delete composite databases using either the command `DROP COMPOSITE DATABASE name` or the more general one `DROP DATABASE name`.
However, keep in mind that the first command targets only composite databases, while the second one targets any database.

.Query
[source, cypher]
----
DROP COMPOSITE DATABASE inventory
----

[role=label--new-5.24]
[[composite-databases-delete-with-aliases]]
== Delete a composite database while dropping its constituents

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.

[NOTE]
====
This operation does not deletes the actual target databases of the constituent database aliases.
====

The `CASCADE ALIASES` option is useful when you want to delete a composite database and its constituent database aliases in one step.
Using `CASCADE ALIASES` requires the `DROP ALIAS` privilege.
For more information about this privilege, see xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-alias-management[ALIAS MANAGEMENT privileges].

.Drop a composite database and its consitutent alias
====
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`.
.Create a composite database `movies` and a database alias `movies.sweden` for the database `swedish-movies`
[source, cypher]
----
CREATE COMPOSITE DATABASE movies
CREATE ALIAS movies.sweden FOR DATABASE `swedish-movies`
----
.Delete the composite database `movies` while also dropping the alias `movies.sweden`
[source, cypher]
----
DROP COMPOSITE DATABASE movies CASCADE ALIASES
----
====

This behavior is the same for the more general command `DROP DATABASE name` when using it to drop a composite database.

The option `RESTRICT` explicitly requests the default behavior of the command.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this section don't have a syntax description nor mention RESTRICT before this point, this sentence sticks out weirdly

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I had this question in my mind: What is the default behavior of the command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to throw an error when there exists aliases (for composite its constituent aliases and for standard it's local ones targeting it), so the behaviour if you don't write CASCADE ALIASES

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. And when or why would one use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really see people using it as it means the same as leaving it out, but it is there for consistency. We do allow you to specify the default behaviours of DUMP DATA/NOWAIT so why wouldn't we allow you to specify RESTRICT

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what to write then. I'll leave it out until we come up with something useful for the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think leaving it out on the composite page is fine


[NOTE]
====
For composite databases, the aliases that are dropped when using the `CASCADE ALIASES` option can be found in the `constituents` column of `SHOW DATABASE`.
====

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Note that all database aliases must be dropped before dropping a database.
|
[source, syntax, role="noheader"]
----
DROP [COMPOSITE] DATABASE name [IF EXISTS] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SEC[OND[S]]]]\|NOWAIT]
DROP [COMPOSITE] DATABASE name [IF EXISTS] [RESTRICT \| CASCADE ALIAS[ES]] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SEC[OND[S]]]]\|NOWAIT]
----

|===
Expand Down Expand Up @@ -92,9 +92,9 @@ In Neo4j, dumps can be stored in the directory specified by the xref:configurati
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`
=== 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.
The options `IF EXISTS` and `DUMP DATA`/`DESTROY DATA` can also be combined.

An example could look like this:

Expand All @@ -103,4 +103,54 @@ An example could look like this:
DROP DATABASE customers IF EXISTS DUMP DATA
----

[[delete-databases-with-aliases]]
=== Delete a database with local database aliases targeting it

There are two ways of dropping a database that is the target of local database aliases:

* Drop the local database aliases first, then use `DROP DATABASE name` to drop the database.
Remote database aliases targeting the database do not affect the deletion of the database and therefore dos not need to be dropped beforehand.
* Use `DROP DATABASE name CASCADE ALIASES` to also drop the local database aliases targeting it while dropping the database.
If any of the dropped database aliases are constituents of composite databases, those composite databases will not be dropped.
This command does not affect the remote database aliases targeting the database being dropped.
They will simply no longer resolve their targets as if they were created targeting a non-existing database.

Using `CASCADE ALIASES` requires the `DROP ALIAS` privilege.
For more information about the privilege, see xref:authentication-authorization/dbms-administration.adoc#access-control-dbms-administration-alias-management[ALIAS MANAGEMENT privileges].

.Drop a database and the local database alias targeting it
====
The following example creates a database `movies` and a local database alias `films` targeting it:

[source, cypher]
----
CREATE DATABASE movies
CREATE ALIAS films FOR DATABASE movies
----

Then, the database `movies` and the local database alias `films` can be dropped using the following command:

[source, cypher]
----
DROP DATABASE movies CASCADE ALIASES
----

====
//The option `RESTRICT` explicitly requests the default behavior of the command.

[NOTE]
====
For standard databases, the aliases that are dropped when using the `CASCADE ALIASES` option can be found in the `aliases` column of `SHOW DATABASE`.
====

[[delete-existing-databases-with-aliases]]
=== Delete a database with `RESTRICT`/`CASCADE ALIASES` and other command parts

The options `RESTRICT`/`CASCADE ALIASES` can also be combined with `IF EXISTS` and `DUMP DATA`/`DESTROY DATA`.
For example:

[source, cypher]
----
DROP DATABASE movies IF EXISTS CASCADE ALIASES DUMP DATA
----

2 changes: 1 addition & 1 deletion modules/ROOT/pages/database-administration/syntax.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ START DATABASE name [WAIT [n [SEC[OND[S]]]]\|NOWAIT]
|
[source, syntax, role="noheader"]
----
DROP [COMPOSITE] DATABASE name [IF EXISTS] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SEC[OND[S]]]]\|NOWAIT]
DROP [COMPOSITE] DATABASE name [IF EXISTS] [RESTRICT \| CASCADE ALIAS[ES]] [{DUMP\|DESTROY} [DATA]] [WAIT [n [SEC[OND[S]]]]\|NOWAIT]
----

|===
Expand Down