Appearance
DROP SCHEMA
Drop a schema from the database.
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
- IF EXISTS
- Do not return a warning if the schema does not exist.
- name
- Name the schema to drop. You can drop multiple schemas with one statement. You must drop schemas from the database where they were created.
- CASCADE
- If other objects depend on the schema, such as tables and views, drop them as well.
- RESTRICT
- If other objects depend on the schema, do not drop the schema. This is the default.
For example:
premdb=# drop schema premdb;
DROP SCHEMA
For example, attempt to drop a schema that has a dependent table:
premdb=# drop schema bobr;
ERROR: cannot drop schema bobr because other objects depend on it
DETAIL: table bobr.new depends on schema bobr
HINT: Use DROP ... CASCADE to drop the dependent objects too.
premdb=# drop schema bobr cascade;
DROP SCHEMA
Parent topic:SQL Commands