ADVERTISEMENT

SQL DROP TABLE

DROP TABLE is used to delete a table permanently from the database along with all its data. Use it carefully!

🔹 Basic Syntax

DROP TABLE table_name;
  • Replace table_name with the name of the table you want to delete.
  • This operation cannot be undone — all data in the table will be lost.

🔹 Example

DROP TABLE employees;

Deletes the employees table and all its data.

🔹 Important Notes

  • You cannot drop a table if other objects depend on it (like foreign keys) without first removing dependencies.
  • Some DBMS support DROP TABLE IF EXISTS to avoid errors if the table doesn’t exist:
DROP TABLE IF EXISTS employees;
  • Be cautious when using this command in production environments.

🧠 Quick Recap

Key PointExplanation
CommandDROP TABLE table_name;
EffectPermanently deletes table & data
WarningIrreversible operation!
Conditional DropDROP TABLE IF EXISTS (optional)

💡 Always double-check before dropping a table to prevent accidental data loss.

ADVERTISEMENT