Last Updated: 28 May, 2023
The DROP DATABASE statement is used to drop an existing database from MySQL.
Deleting a database means all the tables, indexes, views etc. related to the database will deleted.
See the syntax and example below.
Syntax:
DROP DATABASE database_name;
Example:
DROP DATABASE schoolDB;
Drop a database with IF EXISTS option
We can use the IF EXISTS option with the DROP DATABASE statement in MySQL to prevent an error from being thrown if the database we are trying to drop doesn't exist.
Syntax:
DROP DATABASE IF EXISTS database_name;
Example:
DROP DATABASE IF EXISTS schoolDB;
That's all, guys. I hope this MySQL article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com