Drops a schema from the current database. Only the schema owner can execute this command. Also, you cannot drop a schema if it contains any relations.
ImportantDROP SCHEMA cannot be undone. Use it with care!
Arguments
schema_name
The name of the schema to drop. Optionally, a fully-qualified schema name can be provided to drop a schema from a database other than the current database. If the name is case sensitive you must wrap it in double quotes; otherwise the system uses the lower case name.
Examples
Drop a schema in the current database
The following drops the schema in the current database demodb:
demodb.public/demostore#showSCHEMAS;+------------+-------------+------------+-------------------------------+|Name|IsDefault|Owner|CreatedAt|+============+=============+============+===============================+|public|true|sysadmin|2024-07-0216:23:26+0000UTC|+------------+-------------+------------+-------------------------------+|otherdb|false|sysadmin|2024-07-0221:43:27+0000UTC|+------------+-------------+------------+-------------------------------+|newschema|false|sysadmin|2024-07-0315:32:21+0000UTC|+------------+-------------+------------+-------------------------------+demodb.public/demostore#DROPSCHEMAnewschema;+------------+------------------+------------+------------------------------------------+|Type|Name|Command|Summary|+============+==================+============+==========================================+|schema|demodb.newschema|DROP|schema"demodb.newschema"was|||||successfullydropped|+------------+------------------+------------+------------------------------------------+demodb.public/<no-store># LIST SCHEMAS;+------------+-------------+------------+-------------------------------+|Name|IsDefault|Owner|CreatedAt|+============+=============+============+===============================+|public|true|sysadmin|2024-07-0216:23:26+0000UTC|+------------+-------------+------------+-------------------------------+|otherdb|false|sysadmin|2024-07-0221:43:27+0000UTC|+------------+-------------+------------+-------------------------------+
Drop a schema in a specific database
The following drops the schema NewSchema in the specified database otherdb:
demodb.public/<no-store># LIST SCHEMAS IN DATABASE otherdb;+------------+-------------+------------+-------------------------------+|Name|IsDefault|Owner|CreatedAt|+============+=============+============+===============================+|S1|false|sysadmin|2024-07-0221:44:59+0000UTC|+------------+-------------+------------+-------------------------------+|public|true|sysadmin|2024-07-0221:21:18+0000UTC|+------------+-------------+------------+-------------------------------+|NewSchema|false|sysadmin|2024-07-0221:21:25+0000UTC|+------------+-------------+------------+-------------------------------+demodb.public/<no-store># DROP SCHEMA otherdb."NewSchema";+------------+-------------------+------------+------------------------------------------+|Type|Name|Command|Summary|+============+===================+============+==========================================+|schema|otherdb.NewSchema|DROP|schema"otherdb.NewSchema"was|||||successfullydropped|+------------+-------------------+------------+------------------------------------------+demodb.public/<no-store># LIST SCHEMAS IN DATABASE otherdb;+------------+-------------+------------+-------------------------------+|Name|IsDefault|Owner|CreatedAt|+============+=============+============+===============================+|S1|false|sysadmin|2024-07-0221:44:59+0000UTC|+------------+-------------+------------+-------------------------------+|public|true|sysadmin|2024-07-0221:21:18+0000UTC|+------------+-------------+------------+-------------------------------+