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.