DROP SCHEMA — remove a schema
DROP SCHEMA name [ CASCADE | RESTRICT ] [ IF EXISTS ]; DROP SCHEMA [ CASCADE | RESTRICT] [ IF EXISTS ] name;
DROP SCHEMA removes schemas from the database.
CREATE SCHEMA for information on how to create a schema.
Name of the schema
Automatically drops objects such as tables or stored procedures, 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 CASCADEto fail if the transaction isolation level is
CONSISTENT READand 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).
Refuse to drop the schema if it contains any objects. This is the default.
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 1: Creating an object in a schema.
CREATE SCHEMA schema1;
CREATE TABLE schema1.test_table (column1 INTEGER);
- Example 2: Dropping a Non-Empty Schema.
DROP SCHEMA schema1;
Error 42000: schema "SCHEMA1" is not empty and cannot be dropped, it has 1 table, 0 domains, 0 sequences, 0 roles, 0 procedures and 0 functions. CASCADE option can be used to forcibly drop the schema and all related content.
DROP SCHEMA schema1 CASCADE;