DROP SCHEMA

Purpose

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

Prerequisites

  • For physical schema: You need to have the system privilege DROP ANY SCHEMA, or the schema is owned by your current user or one of your roles.
  • For virtual schema: You need to have the system privilege DROP ANY VIRTUAL SCHEMA, or the schema is owned by your current user or one of your 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 exists.
  • 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;