Blog Bustle 29/02/2020
We can delete table from database in mysql using drop table sql query. We can also delete multiple tables from database at a time. Be careful before running mysql drop table sql query because we will lose all information stored in table. Remember that before deleting table first we have to select database.
drop table table_name;
If want to delete table which does not exist in database then we will get 'unknown table' error. So we should use combined syntax of mysql drop table sql query with if exists.
drop table if exists table_name;
drop table table_1, table_2, table_3, .... ;
You can also use this mysql drop table sql query for deleting multiple tables.
drop table if exists table_1, table_2, table_3, .... ;
For example, i have student database. First i will delete class table from student database. After that i will delete employee and subject table together from student database.
So we can delete single or multiple tables using mysql drop table sql query.
1. If we are going to delete table using command line first we have to connect mysql server from command line.
2. Fisrt select database before deleting table otherwise we will get 'no database selected' error.
3. We should have table backup, whom we want to drop, for future use because we will not able to retrieve table data after deleting table.
4. Deleting table from command line is fast process.