SQL DROP Statement
The DROP statement is used to delete object in SQL, with the DROP statement we can remove index, tables and even databases easily.
The indexes of the table can be dropped by the using the following command.
SYNTAX for MS Access
- DROP INDEX index_name
- ON TABLE_NAME
SYNTAX for SQL SERVER
DROP INDEX TABLE_NAME.index_name
SYNTAX for Oracle
DROP INDEX index_name
SYNTAX for MySQL
ALTER TABLE TABLE_NAME DROP INDEX index_name
For various DBMS the respective statement will drop the indexes from the table.
TO DROP TABLES
To drop the tables from the database the following syntax is used and it is same for all DBMS.
DROP TABLE TABLE_NAME
If we do not want to drop the complete table but only want to flush/delete the data inside it you can use the TRUNCATE statement.
TRUNCATE TABLE TABLE_NAME
TO DROP Databases
To drop the complete database we can use the following method and is same across all DBMS.
DROP DATABASE database_name