Home »
MySQL
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;
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;
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:
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,
After clicking on drop schema it will ask you for the final permission,
After clicking on apply a popup box will appear which will ask you to REVIEW SQL or DROP NOW.
Click on DROP NOW, your database will be deleted successfully.