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

# DROP EXTENSION

Use the DROP EXTENSION statement to remove an extension from the database

## Synopsis

Use the `DROP EXTENSION` statement to remove an extension from the database.

## Syntax

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

```output.ebnf
drop_extension ::= DROP EXTENSION [ IF EXISTS ] extension_name 
                   [ , ... ] [ CASCADE | RESTRICT ]
```

#### drop\_extension

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

## Semantics

- An error is thrown if the extension does not exist unless `IF EXISTS` is used. Then, a notice is issued instead.
- `RESTRICT` is the default, and it will not drop the extension if any objects depend on it.
- `CASCADE` drops any objects that transitively depend on the extension.

## Examples

```plpgsql
DROP EXTENSION IF EXISTS cube;
```

```output
NOTICE:  extension "cube" does not exist, skipping
```

```plpgsql
CREATE EXTENSION cube;
CREATE EXTENSION earthdistance;
DROP EXTENSION IF EXISTS cube RESTRICT;
```

```output
ERROR:  cannot drop extension cube because other objects depend on it
DETAIL:  extension earthdistance depends on function cube_out(cube)
HINT:  Use DROP ... CASCADE to drop the dependent objects too.
```

```plpgsql
DROP EXTENSION IF EXISTS cube CASCADE;
```

```output
NOTICE:  drop cascades to extension earthdistance
DROP EXTENSION
```

## See also

- [PostgreSQL Extensions](/stable/additional-features/pg-extensions/ "PostgreSQL Extensions")
- [CREATE EXTENSION](/stable/api/ysql/the-sql-language/statements/ddl_create_extension "CREATE EXTENSION")
