SQL > ALTER TABLE > Drop Index Syntax

Sometimes we may decide that a particular index is no longer needed for a table. In those cases, that index should be removed to free up storage. To drop an index in SQL, we specify that we want to change the table structure via the ALTER TABLE command, followed by the DROP INDEX command.

The SQL syntax to drop an index from a table is,

ALTER TABLE "table_name"
DROP INDEX "index_name";

Let's look at the example. Assuming our starting point is the Customer table created in the CREATE TABLE section:

Table Customer

Column NameData Type
First_Namechar(50)
Last_Namechar(50)
Addresschar(50)
Citychar(50)
Countrychar(25)
Birth_Datedatetime

Assume we want to drop the index created in the ALTER TABLE ADD INDEX section. To do this, we type in the following:

ALTER TABLE Customer DROP INDEX IDX_COUNTRY;

Please note that using ALTER TABLE to drop an index in supported in MySQL but not in Oracle or SQL Server.

Next: SQL ADD CONSTRAINT




Copyright © 2014   1keydata.com   All Rights Reserved.     Privacy Policy