DROP SCHEMA removes a user-defined .
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 schema and on all tables in the schema. If the user is the owner of the schema, DROP privileges are not necessary.
Syntax
Parameters
| Parameter | Description |
|---|---|
IF EXISTS | Drop the schema if it exists. If it does not exist, do not return an error. |
schema_name_list | The schema, or a list of schemas, that you want to drop. To drop a schema in a database other than the current database, specify the name of the database and the name of the schema, separated by a “ .” (e.g., DROP SCHEMA IF EXISTS database.schema;). |
CASCADE | Drop all tables and views in the schema as well as all objects (such as and ) that depend on those tables.CASCADE does not list objects it drops, so should be used cautiously. |
RESTRICT | (Default) Do not drop the schema if it contains any or . |
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 schema
Drop a schema with tables
To drop a schema that contains tables, you need to use theCASCADE keyword.

