← Back to Chapters

MySQL DROP DATABASE

?️ MySQL DROP DATABASE

? Quick Overview

The DROP DATABASE statement permanently removes a MySQL database along with all its tables, views, procedures, and data.

?️ Key Concepts

  • Permanent action — data cannot be recovered without backup.
  • Admin Task — usually requires database-level privileges.
  • Whole DB — deletes everything inside the database.

? Syntax / Theory

? View Code Example
-- General syntax to remove a MySQL database
DROP DATABASE database_name;

? Code Example

? View Code Example
-- Deletes the EmployeeDB database completely
DROP DATABASE EmployeeDB;

? Live Output / Explanation

? What Happens?

  • The database EmployeeDB is instantly removed from the server.
  • All tables and records inside it are deleted.
  • The database will no longer appear in the result of SHOW DATABASES;.

? Use Cases

  • Removing test or temporary databases.
  • Cleaning unused databases from the server.
  • Resetting a development environment.

✅ Tips & Best Practices

  • Always take a backup before dropping a database.
  • Run SHOW DATABASES; to confirm the name before deletion.
  • Avoid running this command in production systems without approval.

? Try It Yourself

  • Create a database using CREATE DATABASE TestDB;.
  • Verify using SHOW DATABASES;.
  • Delete it with DROP DATABASE TestDB;.
  • Confirm removal using SHOW DATABASES; again.