Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learn SQL using MySQL in One Day and Learn It Well

You're reading from  Learn SQL using MySQL in One Day and Learn It Well

Product type Book
Published in Apr 2024
Publisher Packt
ISBN-13 9781836205678
Pages 121 pages
Edition 1st Edition
Languages
Author (1):
Jamie Chan Jamie Chan
Profile icon Jamie Chan
Toc

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;

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}