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 Point | Explanation |
---|---|
Command | DROP DATABASE database_name; |
Effect | Deletes entire database & data |
Warning | Irreversible operation! |
DBMS Differences | Oracle requires special steps |
💡 Always double-check before dropping a database to avoid accidental data loss.