select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQL COMMANDS / EXTENSIONS & ACCESS METHODS

DROP EXTENSION

Read PG 18 manual ↗

remove an extension

Syntax

DROP EXTENSION [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
Syntax diagrams

Read left to right. Branches are choices, bypasses are optional, loops repeat. Select an underlined parameter to open its rule.

DROP EXTENSION IF EXISTS name , CASCADE RESTRICT

Description

DROP EXTENSION removes extensions from the database. Dropping an extension causes its member objects, and other explicitly dependent routines (see ALTER ROUTINE, the DEPENDS ON EXTENSION extension_name action), to be dropped as well.

You must own the extension to use DROP EXTENSION.

Parameters

IF EXISTS

Do not throw an error if the extension does not exist. A notice is issued in this case.

name

The name of an installed extension.

CASCADE

Automatically drop objects that depend on the extension, and in turn all objects that depend on those objects (see Section 5.15).

RESTRICT

This option prevents the specified extensions from being dropped if other objects, besides these extensions, their members, and their explicitly dependent routines, depend on them. This is the default.

Examples

To remove the extension hstore from the current database:

DROP EXTENSION hstore;

This command will fail if any of hstore's objects are in use in the database, for example if any tables have columns of the hstore type. Add the CASCADE option to forcibly remove those dependent objects as well.

Compatibility

DROP EXTENSION is a PostgreSQL extension.

See Also

CREATE EXTENSION, ALTER EXTENSION
Version history 6
  1. PG 19 → 20changed
  2. PG 18 → 19changed
  3. PG 16 → 17changed
  4. PG 13 → 14changed
  5. PG 12 → 13changed
  6. PG 11 → 12changed

Related entries

Definition snapshot: 2026-09-14T13:14:25.700916+00:00@99e6866c · English manual source