Overview
The DROP SCHEMA statement deletes a specified schema along with all database objects within it. Before performing this operation, ensure you back up all critical data to prevent data loss.
Syntax
Parameters
schema_name: Specifies the name of the schema to drop.IF EXISTS: An optional parameter that prevents errors if the specified schema does not exist.
Examples
-
Drop the schema named
deprecated_schema: -
Drop the schema but suppress errors if it does not exist:
Notes
- Executing
DROP SCHEMAirreversibly deletes the entire schema and all objects it contains (tables, views, indexes, etc.). Before performing this operation, ensure all important data has been backed up. - This operation can only be executed by users with the appropriate privileges. If you lack sufficient privileges, the operation will fail with an error.
Required Privileges
The user executing DROP SCHEMA must have the DROP privilege on the corresponding schema. If you do not have the required privileges, the operation will fail with an error.
