The DROP DATABASE
statement is used for deleting a database and all of its tables completely.
Syntax:
DROP DATABASE DBName;
Here DBName is the name of the database which you want to delete.
Example – The below statement would delete the database named “Student”.
SQL> DROP DATABASE Student;
Note: By deleting a database you delete all of its tables implicitly. For e.g. the above statement would delete all the tables that are stored inside “Student” database, along with the database.
After dropping a database you can check the database list to cross verify that the database has been successfully dropped or not. This is how you can do it.
Before deleting “Student” Database:
SQL> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | Abc | | Xyz | | Student | | Demo | | Test | +--------------------+ 5 rows in set (0.00 sec)
After deleting “Student” Database:
SQL> DROP DATABASE Student;
List down the databases:
SQL> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | Abc | | Xyz | | Demo | | Test | +--------------------+ 4 rows in set (0.00 sec)
Leave a Reply