SQL DELETE DATABASE

The DELETE operation does not directly apply to an entire database. Instead, the DROP DATABASE statement is used to completely remove a database and all its objects (tables, views, stored procedures, etc.).

Caution should be exercised when performing this operation, as it is irreversible. Ensure you have a backup before proceeding.

Example

This example demonstrates deleting an entire database named SalesDB.

Code Example


-- Drop the SalesDB database
DROP DATABASE SalesDB;

-- Verify the database is removed
SHOW DATABASES;
            

Output

Database
information_schema
mysql
performance_schema

Explanation

- The DROP DATABASE statement completely removes the SalesDB database.
- After execution, SHOW DATABASES confirms the absence of the deleted database.
- Use this command only when you are sure you no longer need the database and its data.