# Delete Table

The DELETE statement removes rows from a table. You specify which table to remove data from and can use a WHERE clause to filter which rows should be deleted based on specific conditions. If no WHERE clause is provided, all rows in the table will be deleted.

# Truncate Table

Truncate Table is a command in SQL used to remove all rows from a table. It’s like resetting the table to its initial, empty state. The table structure itself (columns, data types, constraints) remains intact. TRUNCATE TABLE is generally faster than DELETE because it deallocates the data pages used by the table, rather than individually logging each row deletion.

# Drop Table

The DROP TABLE statement removes a table and its data entirely from a database. It’s a permanent operation; once a table is dropped, its structure and all the data it contained are lost unless you have a backup. This command should be used with caution, as it can have significant consequences for your database.

FeatureDELETETRUNCATE TABLEDROP TABLE
PurposeRemoves specific or all rowsRemoves all rowsDeletes entire table
WHERE ClauseSupportedNot supportedNot applicable
Table StructureRemains intactRemains intactCompletely removed
Data RemovalRow-by-rowAll rows at onceTable + data removed
SpeedSlower (logs each row deletion)Faster (deallocates data pages)Very fast
LoggingFully loggedMinimal loggingMinimal logging
RollbackPossible (in transactions)DB-dependentNot possible in most cases
Auto IncrementNot resetReset (in most DBs)Removed with table
TriggersFires triggersDoes NOT fire triggersNot applicable
Space HandlingSpace not fully released immediatelyFrees table data spaceFrees table + structure completely
Use CaseDelete specific rowsQuickly clear entire tableRemove table permanently

# Alter Table

The ALTER TABLE statement in SQL is used to modify the structure of an existing table. This includes adding, dropping, or modifying columns, changing the data type of a column, setting default values, and adding or dropping primary or foreign keys.