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.