Delete composite databases

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.

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 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
DROP COMPOSITE DATABASE inventory

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.

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 ALIAS MANAGEMENT privileges.

Example 1. 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
CREATE COMPOSITE DATABASE movies
CREATE ALIAS movies.sweden FOR DATABASE `swedish-movies`
Delete the composite database movies while also dropping the alias movies.sweden
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.

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