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.