MySQL – Drop Database
The Drop database statement removes all tables from the database and deletes the database permanently. Therefore, it is very important to use this statement with caution.
Drop database statement syntax is as follows:
DROP DATABASE [IF EXISTS] database_name;
A Drop database statement specifies the name of the database to be deleted after the DROP DATABASE keyword.
A MySQL error will be generated if you drop a database that does not exist.
The IF EXISTS option can be used to prevent an error from occurring if you delete a database that does not exist. MySQL will terminate the statement without issuing an error message in this situation.
Drop database returns the number of tables that have been deleted.
The schema is a synonym for the database in MySQL. As a result, they can be used interchangeably.
DROP SCHEMA [IF EXISTS] database_name;
Drop the “Demodatabase” database by issuing the DROP DATABASE command:
Output: