ADVERTISEMENT

SQL DROP DATABASE

DROP DATABASE is used to delete an existing database permanently along with all its tables, data, and objects. Use it with care!

🔹 Basic Syntax

DROP DATABASE database_name;
  • Replace database_name with the name of the database you want to delete.
  • This action cannot be undone — all data will be lost.

🔹 Example

DROP DATABASE sales_db;

Deletes the sales_db database entirely.

🔹 Important Notes

  • Some DBMS like MySQL allow DROP DATABASE only if no active connections exist.
  • In SQL Server, ensure no users are connected, or you might get an error.
  • In Oracle, there’s no simple DROP DATABASE command; it involves more steps (like dropping the entire database instance).

🧠 Quick Recap

Key PointExplanation
CommandDROP DATABASE database_name;
EffectDeletes entire database & data
WarningIrreversible operation!
DBMS DifferencesOracle requires special steps

💡 Always double-check before dropping a database to avoid accidental data loss.

ADVERTISEMENT