DROP SCHEMA
DROP SCHEMA
— remove a schema
Syntax
DROP SCHEMA name [ CASCADE | RESTRICT ] [ IF EXISTS ]
DROP SCHEMA [ CASCADE | RESTRICT] [ IF EXISTS ] name
Description
DROP SCHEMA
removes schemas from the database.
Refer to CREATE SCHEMA
for information on how to create a schema.
Parameters
name
-
Name of a schema
CASCADE
-
Automatically drops objects (tables, stored procedures, etc.) that are contained in the schema. This option can be used to forcibly drop all related schema, if required. See Dropping a Non-Empty Schema.
It is possible for DROP SCHEMA CASCADE
to fail if the transaction isolation level isCONSISTENT READ
and objects are created concurrently in the schema by other transactions. In this case, the "can’t find <object> name" error message is returned, where object is the type of the object created concurrently (for example, table). RESTRICT
-
Refuse to drop the schema if it contains any objects. This is the default.
IF EXISTS
-
If the schema does not exist and you specify
IF EXISTS
, NuoDB does not generate an error. Otherwise, if the schema does not exist, an error is generated.
Example
Create objects in a schema. Drop the schema.
CREATE SCHEMA schema1
CREATE DOMAIN schema1.test_domain INTEGER;
CREATE TABLE schema1.test_table (column1 test_domain);
DROP SCHEMA schema1;
schema "SCHEMA1" has 1 domain, 0 sequences, 0 roles, and 0 procedures. CASCADE will drop all
DROP SCHEMA schema1 CASCADE;
Dropping a Non-Empty Schema
DROP SCHEMA PROD;
When dropping a non-empty schema the following error message is displayed:
schema "PROD" is not empty and cannot be dropped, it has 0 domains, 2 sequences, 0 roles, 0 procedures and 0 functions. CASCADE option can be used to forcibly drop the schema and all related content.