MySQL

How to Delete Database in MySQL

In this tutorial, we are going to see how to delete a database in MySQL. You can delete a MySQL database with DROP DATABASE command. It permanently deletes all tables in the database as well as the database. It generates an error if the database does not exist. We can use IF EXISTS option with DROP DATABASE command.

DROP DATABASE command returns the number of deleted tables. We have to be careful when deleting any database because we will lose all available data in the database.
 

 

Syntax:
DROP DATABASE databaseName;

 

Example:

Let’s take an example to delete a database named “bibliotheque”.

DROP DATABASE bibliotheque;


 
You can now check that your database is deleted by running the following query:

SHOW DATABASES;


 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *