PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References
PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References

PostgreSQL DROP INDEX Keyword



The PostgreSQL DROP INDEX keyword is used to delete a index on a table. Indexes are useful to retrieve data from the database more quickly and speeds up the search queries. Indexes are not visible to the end users. Along with this, updating a table with indexes takes more time as compared to a table without any indexes because indexes are updated. Therefore it is advised to create indexes only on frequently searched columns.

The INSERT and UPDATE statements take more time on tables having indexes, whereas the SELECT statements become fast on those tables. The reason is that while performing insert or update operation, the database update the indexes as well.

PostgreSQL DROP INDEX

The PostgreSQL DROP INDEX statement is used to delete a index on a table.

Syntax

The syntax for using DROP INDEX statement in PostgreSQL is given below:

DROP INDEX [IF EXISTS] index_name;

The IF EXISTS is an optional parameter that conditionally drops index only if it exists on the database system. If a index is deleted which does not exist, it will raise an error.

PostgreSQL DROP INDEX Example

Consider a database which contains an index named idx_name. To drop this index, the following statement can be used:

DROP INDEX idx_name;

❮ PostgreSQL Keywords