MySQL DROP DATABASE Statement

MySQL | DROP DATABASE: Learn about the MySQL DROP DATABASE Statement, with its explanation, syntax, and query examples.
Submitted by Apurva Mathur, on September 03, 2022

DROP DATABASE Statement

In MySQL, if we don't want to keep any database we can remove it/delete it. Deleting something in MySQL is commonly referred to as DROP. When we are dropping/ deleting a database it deletes all the details including tables.

Points to keep in mind while deleting a database:

  • Always think twice whenever you are deleting a database as your database may contain some important details and if you are deleting your database all its data will be lost.
  • Whenever you are deleting a database, write the correct name else it will show you an error.
  • Always create a backup of your database, as it will help you if you need it after deletion.

Now let us see how we drop a database both in the MySQL command line client and in the MySQL workbench.

Dropping Database in Command-Line Client

In the MySQL command-line client we the following syntax.

Syntax:

DROP DATABASE DATABASE_NAME;
DROP DATABASE Statement (Step 1)

Here in the given picture as you can see, I have many databases now if want to delete the database named as a "student" then I'll simply write the DROP DATABASE statement.

DROP DATABASE student;
DROP DATABASE Statement (Step 2)

As you can see once I've deleted my database it is no more visible in the list.

Dropping Database in MySQL Workbench

Now we'll see how we drop a database in MySQL Workbench.

I have the following schemas in the MySQL workbench:

DROP DATABASE Statement (Step 3)

Now if we want to drop the schema named "new_student_database", then we'll right-click on the particular schema we want to drop and then we'll click on drop schema, as shown below,

DROP DATABASE Statement (Step 4)

After clicking on drop schema it will ask you for the final permission,

DROP DATABASE Statement (Step 5)

After clicking on apply a popup box will appear which will ask you to REVIEW SQL or DROP NOW.

DROP DATABASE Statement (Step 6)

Click on DROP NOW, your database will be deleted successfully.




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.