SQL DROP TABLE Statement

The DROP TABLE statement in SQL is used to permanently delete a table from a database. This is a powerful command, so use it with extreme caution!



DROP TABLE: Definition and Usage

Dropping a table removes the table structure and all data within it. This action is irreversible (unless you have a backup), so always ensure you understand the implications before executing this command.

Syntax

Syntax

DROP TABLE table_name;
      

Example

Dropping a Table

This example drops the 'Shippers' table.

Syntax

DROP TABLE Shippers;
      
Output

The 'Shippers' table and all its data are permanently deleted.

TRUNCATE TABLE Statement

The TRUNCATE TABLE statement removes all data from a table but leaves the table structure intact. This is faster than deleting rows individually but it's still a destructive operation. It's generally quicker than using DELETE to remove all rows.

TRUNCATE TABLE Syntax

Syntax

TRUNCATE TABLE table_name;