SQL DROP INDEX Keyword
The DROP INDEX
command is used to remove an index from a table. Indexes speed up queries, but removing unnecessary indexes can sometimes improve performance for update operations.
Dropping an Index
The syntax for dropping an index varies slightly depending on the database system you're using. Here's how to do it in a few popular systems.
MS Access
In MS Access, you specify the index name and the table name.
Syntax
DROP INDEX index_name
ON table_name;
Output
The index named 'index_name' is removed from the table 'table_name'.
SQL Server
In SQL Server, the table name is part of the index name specification (using dot notation).
Syntax
DROP INDEX table_name.index_name;
Output
The index named 'index_name' (belonging to the table 'table_name') is removed.
DB2/Oracle
In DB2 and Oracle, only the index name is needed to drop the index.
Syntax
DROP INDEX index_name;
Output
The index named 'index_name' is removed.
MySQL
In MySQL, you use the ALTER TABLE
command to drop an index.
Syntax
ALTER TABLE table_name
DROP INDEX index_name;
Output
The index named 'index_name' is removed from the table 'table_name'.