DROP DATABASE

statementsupportedDatabases & schemas

docs.snowflake.com ↗

Object: DATABASE

Removes a database from the system.

Syntax

supportedpartialnot supportednot scored

DROP DATABASE [ IF EXISTS ] <name> [ CASCADE | RESTRICT ]

Parameters

NameRequiredDescription
nameSpecifies the identifier for the database to drop. If the identifier contains spaces, special characters, or mixed-case characters, the entire string must be enclosed in double quotes. Identifiers enclosed in double quotes are also case-sensitive.
CASCADE | RESTRICTSpecifies whether the database can be dropped if foreign keys exist that reference any tables in the database: CASCADE drops the database and all objects in the database, including tables with primary/unique keys that are referenced by foreign keys in other tables. RESTRICT returns a warning about existing foreign key references and does not drop the database. Default: CASCADE

Usage notes

Database replication usage notes

- You can drop a secondary database at any time. Only the database owner (i.e. the role with the OWNERSHIP privilege on the database) can drop the database. - A primary database cannot be dropped if one or more replicas of the database (i.e. secondary databases) exist. To drop the primary database, first promote a secondary database to serve as the primary database, and then drop the former primary database. Alternatively, drop all of the secondary databases for the primary database, and then drop the primary database. Note that only the database owner can drop the database.

See also

Referenced by