In this topic, we described about the DELETE DATABASE with detailed example.
DROP DATABASE statement used to delete existing database that is not using from long time or no use in future. Deleting database, deletes all the database elements like tables, views, indexes etc, also gets deleted. Once we DROP database, we may not get the data recovered from the database. So, be careful while using DROP statement.
DROP DATABASE database_name;
- database_name – Specifies the name of the database.
let us assume, we have a database called Demo.
Scenario – Deleting existing database.
Requirement - Deleting existing Demo database. The query was as follows –
DROP DATABASE Demo;
By executing above query, we can delete existing Demo database.
Scenario – Verifying deleting existing database.
Requirement – Verifying existing Demo database deleted or not. The query was as follows –
By using above query, either one of the below things happen.
If database not deleted, we could set "Demo" database as current database. Otherwise, we can get error like as follows -
"Database 'Demo' does not exist. Make sure that the name is entered correctly."