---
title: "DROP SCHEMA"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_drop_schema/"
---

# DROP SCHEMA

Use the DROP SCHEMA statement to remove a schema and all of its associated objects from the system.

## Synopsis

Use the `DROP SCHEMA` statement to remove a schema and all of its associated objects from the system. This is an irreversible statement.

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

```output.ebnf
drop_schema ::= DROP SCHEMA [ IF EXISTS ] schema_name [ , ... ] 
                [ CASCADE | RESTRICT ]
```

#### drop\_schema

DROPSCHEMAIFEXISTS,[schema\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#schema-name)CASCADERESTRICT

## Semantics

- `DROP SCHEMA... CASCADE` executes in a single transaction so that *either* it has no effect (if it's interrupted) *or* the nominated schema together with all the objects in it are dropped.

### *drop\_schema*

#### DROP SCHEMA \[ IF EXISTS ] *schema\_name*

Remove a schema from the database. The schema can only be dropped by its owner or a superuser.

### *schema\_name*

Specify the name of the schema.

### *CASCADE*

Remove a schema and all associated objects. All objects that are associated with `schema_name` such as tables will be invalidated after the drop statement is completed.

### *RESTRICT*

Refuse to drop the schema if it contains any objects. This is the default.

## Example

Create a schema with a table:

```sql
CREATE SCHEMA sch1;
CREATE TABLE sch1.t1(id BIGSERIAL PRIMARY KEY);
```

Try to drop the schema:

```sql
DROP SCHEMA sch1;
ERROR:  cannot drop schema sch1 because other objects depend on it
DETAIL:  table sch1.t1 depends on schema sch1
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
```

Drop a schema with `CASCADE`:

```sql
DROP SCHEMA sch1 CASCADE;
NOTICE:  drop cascades to table sch1.t1
DROP SCHEMA
```

## See also

- [CREATE SCHEMA](/stable/api/ysql/the-sql-language/statements/ddl_create_schema "CREATE SCHEMA")
- [ALTER SCHEMA](/stable/api/ysql/the-sql-language/statements/ddl_alter_schema "ALTER SCHEMA")
