SQL - Drop Database

The SQL statement used to drop a database is DROP DATABASE. It is used to permanently remove an existing database and all its associated objects, including tables, views, indexes, and data.



DROP DATABASE database_name;

Where database_name is the name of the database you want to drop.



DROP DATABASE mydatabase;

This will drop the database named "mydatabase" if it exists. If the database doesn't exist, an error will occur unless you use the IF EXISTS clause to avoid the error:


The IF EXISTS clause ensures that no error is thrown if the database doesn't exist.

Please note that dropping a database is a potentially destructive operation, as it permanently deletes all data and objects associated with the database. It's important to use this statement with caution and make sure you have a backup of the data if needed. Additionally, the exact syntax and behavior of the DROP DATABASE statement may vary depending on the specific database management system you are using.