Deleting the Database
Now, suppose after you create your database, you realise that you have typed the name wrongly. There is no easy way to rename a database in MySQL. What you can do is create a new database and delete the old database. To delete a database, we use the syntax
DROP DATABASE [IF EXISTS] name_of_database;
You can see that we used square brackets [ ] in the DROP DATABASE syntax above. These brackets will be used throughout the book to indicate optional content.
In other words, when deleting a database, the IF EXISTS keywords are optional. We use them to prevent an error from occurring when we accidentally try to delete a database that does not exist.
For instance, to delete a database called wrongDB, we write
DROP DATABASE IF EXISTS wrongDB;
However, if we are certain that wrongDB exists, we can simply write
DROP DATABASE wrongDB;