
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove a MySQL Database
To remove any database, we need to use DROP command in MySQL. Here is the syntax.
DROP DATABASE yourDatabaseName;
First, let us check how many databases are present in MySQL. Here is the query for the same.
mysql> SHOW DATABASES;
The following is the output.
+--------------------+ | Database | +--------------------+ | business | | database1 | | databasesample | | education | | hello | | information_schema | | javadatabase | | javadatabase2 | | javasampledatabase | | mybusiness | | mydatabase | | mysql | | performance_schema | | sample | | sampledatabase | | schemasample | | sys | | test | | test3 | | universitydatabase | +--------------------+ 20 rows in set (0.00 sec)
As displayed above, we have total 20 databases in MySQL. Here, let us try to remove database ?javadatabase'.
The following is the query to remove database.
mysql> DROP DATABASE javadatabase; Query OK, 0 rows affected (0.19 sec)
We have successfully removed the "javadatabase". To verify, let us check with the help of SHOW command.
mysql> show databases;
The following is the output.
+--------------------+ | Database | +--------------------+ | business | | database1 | | databasesample | | education | | hello | | information_schema | | javadatabase2 | | javasampledatabase | | mybusiness | | mydatabase | | mysql | | performance_schema | | sample | | sampledatabase | | schemasample | | sys | | test | | test3 | | universitydatabase | +--------------------+ 19 rows in set (0.00 sec)
The above output displays 10 databases now i.e. we have successfully removed the "javadatabase". Now, you can't find any database with the name "javadatabase".
Advertisements