DROP SCHEMA

Purpose

This statement deletes a schema and subsequently deletes all the objects with it.

Prerequisites

Physical Schema

  • You need the system privilege DROP ANY SCHEMA, or the schema must be owned by you or one of your assigned roles.

Virtual Schema

  • You need the system privilege DROP ANY VIRTUAL SCHEMA, or the schema must be owned by you or one of your assigned roles.

Syntax

drop_schema::=

Drop Schema Statement

Drop Schema Statement

Usage Notes

  • A user can own arbitrary many schemas.
  • RESTRICT deletes the schema only if it is empty.
  • CASCADE deletes the schema and subsequently deletes all objects contained in it. Additionally, all foreign key references to tables within the deleted schema are also removed.
  • If neither CASCADE nor RESTRICT is specified, then RESTRICT is applied by default.
  • If the optional clause IF EXISTS is specified, then the statement will not throw an exception if the schema does not exist.
  • For details about the virtual schema concept, refer to Virtual Schemas section.
  • If you specify the FORCE option in the statement, then the corresponding adapter script is not informed by that action. Otherwise, the adapter script will be called and there will be an action depending on its implementation.

Examples

DROP SCHEMA my_schema;
DROP SCHEMA IF EXISTS my_schema;
DROP SCHEMA my_schema CASCADE;
DROP VIRTUAL SCHEMA my_virtual_schema;