DROP TABLE is used to delete the tables in our database. For example,
DROP TABLE my_table;
Here, the SQL command will delete a table named my_table.
Also make sure you have admin or DROP permission to run this command.
Note: When we delete a database table, all records within a table are also deleted.
DROP TABLE IF EXISTS
While dropping a table that does not exist, throws an error. To fix this issue, we can add an optional
IF EXISTS command while dropping a table. For example,
DROP TABLE IF EXISTS my_table;
Here, the SQL command will only drop a table if there is one with a same name.