DROP INDEX

Name

DROP INDEX -- remove an index

Synopsis

DROP INDEX [ CONCURRENTLY ] [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

Description

DROP INDEX drops an existing index from the database system. To execute this command you must be the owner of the index.

Parameters

IF EXISTS

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

CONCURRENTLY

When this option is used, PostgreSQL will drop the index without taking any locks that prevent concurrent selects, inserts, updates, or deletes on the table; whereas a standard index drop waits for a lock that locks out everything on the table until it's done. Concurrent drop index is a two stage process. First, we mark the index both invalid and not ready then commit the change. Next we wait until there are no users locking the table who can see the index.

There are several caveats to be aware of when using this option. Only one index name can be specified if the CONCURRENTLY parameter is specified. Regular DROP INDEX command can be performed within a transaction block, but DROP INDEX CONCURRENTLY cannot. The CASCADE option is not supported when dropping an index concurrently.

name

The name (optionally schema-qualified) of an index to remove.

CASCADE

Automatically drop objects that depend on the index.

RESTRICT

Refuse to drop the index if any objects depend on it. This is the default.

Examples

This command will remove the index title_idx:

DROP INDEX title_idx;

Compatibility

DROP INDEX is a PostgreSQL language extension. There are no provisions for indexes in the SQL standard.

See Also

CREATE INDEX