Contents
DROP INDEX
An SQL command for removing an index
DROP INDEX
is a DDL command for removing an index.
DROP INDEX
has always been present in PostgreSQL.
Change history
- PostgreSQL 9.2
DROP INDEX CONCURRENTLY
syntax added (commit 8cb53654)
- PostgreSQL 8.2
DROP INDEX IF EXISTS ...
syntax added (commit daea4d8e)
- PostgreSQL 7.3
CASCADE
andRESTRICT
clauses added (commit 7c6df91d)
Examples
Basic execution example for DROP INDEX
:
postgres=# DROP INDEX ocr_uripart_ix; DROP INDEX
Safely attempting to drop an index which might not exist:
postgres=# DROP INDEX IF EXISTS foo; NOTICE: index "foo" does not exist, skipping DROP INDEX
Attempting to drop an index associated with a constraint:
postgres=# DROP INDEX category_pkey; ERROR: cannot drop index category_pkey because constraint category_pkey on table category requires it HINT: You can drop constraint category_pkey on table category instead.
References
- PostgreSQL documentation: DROP INDEX