The RENAME command is used to rename a table. The basic syntax of RENAME command is as follows :
RENAME TABLE old_table_name to new_table_name;
Example :
RENAME TABLE Employee to EmployeeList;
The above statement will rename the table EmployeeList to EmpLst.


The DROP command is used to drop or delete tables, functions, procedures, packages, views, synonym, sequences, table spaces etc. For example with DROP TABLE command we can completely delete a table from a database, and this command will also destroy the table structure. The basic syntax of DROP TABLE statement is as follows :
DROP TABLE table_name;
Example :
DROP TABLE Employee;
The above statement will delete the Employee table completely. We can also delete a database by using the DROP DATABASE command. The basic syntax of DROP DATABASE statement is as follows :
DROP DATABASE database_name;
Example :
The above statement will delete the the database named myDB from the system.


The TRUNCATE command is used to delete all the rows of an existing table, but unlike DROP TABLE command, it will not destroy the table's structure. The basic syntax of TRUNCATE TABLE command is as follows :
TRUNCATE TABLE table_name;
Example :
The above query will delete all the records from Employee table. And remember when we apply truncate command on a table, then its Primary key is re-initialized. For example if we have a table with 10 rows and an auto_increment primary key, and if we use DELETE command to delete all the rows, then it will delete all the rows, but will not initialize the primary key, hence if you will insert any row after using delete command, the auto_increment primary key will start from 11. But in case of truncate command, primary key is re-initialized.

Next Topic :