DROP INDEX¶
DROP INDEX statement is used to remove an existing index from a table. This can be useful when an index is no longer needed, or if you want to free up storage space and reduce maintenance overhead associated with maintaining the index.
Syntax¶
table_name: The name of the table containing the index to be dropped.index_name: The name of the index to be dropped.
Note that only one index can be dropped at a time using the DROP INDEX statement. If you want to drop multiple indexes, you need to execute multiple DROP INDEX statements.
Example¶
Consider the following table called Students with an index on the id column:
You can drop the idx_id index with the following statement:
If you attempt to drop multiple indexes in a single statement, an error will be raised:
This will result in an error, as only one index can be dropped at a time. To drop both indexes, execute two separate DROP INDEX statements: