DROP DATABASE removes a database and all its objects from a CockroachDB cluster.
The “ statement performs a schema change. For more information about how online schema changes work in CockroachDB, see .
Required privileges
The user must have theDROP on the database and on all tables in the database.
Synopsis
Parameters
Viewing schema changes
This schema change statement is registered as a job. You can view long-running jobs with .Examples
Setup
The following examples use MovR, a fictional vehicle-sharing application, to demonstrate CockroachDB SQL statements. For more information about the MovR example application and dataset, see . To follow along, run to start a temporary, in-memory cluster with themovr dataset preloaded:
Drop a database and its objects (CASCADE)
For non-interactive sessions (e.g., client applications), DROP DATABASE applies the CASCADE option by default, which drops all tables and views in the database as well as all objects (such as and ) that depend on those tables.
For interactive sessions from the , either the CASCADE option must be set explicitly or the --unsafe-updates flag must be set when starting the shell.
Prevent dropping a non-empty database (RESTRICT)
When a database is not empty, the RESTRICT option prevents the database from being dropped:

