SQL undoes the index, undoes the table, and undoes the database


By using DROP statements, you can easily delete indexes, tables, and databases.


DROP INDEX statement


The DROP INDEX statement is used to remove the index from the table.

DROP INDEX syntax for MS Access:

DROP INDEX index_name ON table_name      

DROP INDEX syntax for MS SQL Server:

DROP INDEX table_name.index_name     

DROP INDEX syntax for DB2/Oracle:

DROP INDEX index_name   

DROP INDEX syntax for MySQL:

ALTER TABLE table_name DROP INDEX index_name       

DROP TABLE statement


The DROP TABLE statement is used to delete the table.

DROP TABLE table_name      

DROP DATABASE statement


The DROP DATABASE statement is used to delete the database.

DROP DATABASE database_name    

TRUNCATE TABLE statement


What should we do if we just need to delete the data in the table instead of the table itself?

Using the TRUNCATE TABLE statement:

TRUNCATE TABLE table_name