Course
Drop Database
MySQL Tutorial
This SQL tutorial is structured for beginners to guide them from the foundational concepts to advanced data manipulation and querying techniques in SQL. By the end of this tutorial, you will have developed a robust understanding of SQL, equipping you with the knowledge to efficiently manage and analyze data across various database systems. This guide sets the stage for your growth into a skilled data professional, ready to tackle complex data challenges and contribute to the field of data analysis and database management.
DROP DATABASE Statement
MySQL DROP DATABASE Statement
You can drop/delete an existing database using the DROP DATABASE Statement.
Syntax
Following is the syntax of the DROP DATABASE statement
DROP DATABASE database_name;
Where, database_name is the name of the database you need to delete.
Example
Suppose we have created databases as shown below
CREATE DATABASE testDB1;CREATE DATABASE testDB2;CREATE DATABASE testDB3;CREATE DATABASE testDB4;
If you verify the list of databases you can observe the created ones in the list as follows
show databases;
Output
The above mysql query will genrate the following output
You can delete three of the above created databases using the DROP DATABASE statement as shown below
DROP DATABASE testDB1;DROP DATABASE testDB2;DROP DATABASE testDB3;
Make sure you have the admin privilege before dropping any database. Once a database is dropped, if you can verify the list of the tables as shown below you can see its name is missing
show databases;
Output
Following is the output of the above query