DROP Statement

Part of the SQL Data Definition Language (DDL), the DROP statement is used to remove individual tables or entire databases.

Be careful when using this statement, as all the tables and data stored in them are removed and cannot be restored. This statement is often exploited by cyber criminals in SQL injections.

The DROP statement can be used to permanently remove an entire database.

DROP DATABASE databaseName;

It can also be used to delete individual tables from a database. Used in this format, the statement results in the complete loss of all data stored in the named table.

DROP TABLE tableName;

EXISTS (not required for course)

Use the DROP command to remove a a database/table will create an error if the database/table  does not exist, and halt execution of further coammands.

Checking if the database/table exists will removed will prevent this error:

DROP DATABASE IF EXISTS databaseName;
DROP TABLE IF EXISTS tableName;