The TRUNCATE TABLE statement removes all the rows from a table more quickly than a DELETE. Logically, TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause.
The TRUNCATE TABLE statement removes all the rows from a table, but the table structure and its columns, constraints, indexes, and so on remain intact. To remove the table definition in addition to its data, you can use the DROP TABLE statement.
The basic syntax of
TRUNCATE TABLE can be given with:
TRUNCATE TABLE seem to have the same effect, but they do work differently. Here are some major differences between these two statements:
TRUNCATE TABLEstatement drop and re-create the table in such a way that any
DELETElets you filter which rows to be deleted based upon an optional
TRUNCATE TABLEdoesn't support
WHEREclause it just removes all the rows.
TRUNCATE TABLEis faster and uses fewer system resources than
DELETEscans the table to generate a count of rows that were affected then delete the rows one by one and records an entry in the database log for each deleted row, while
TRUNCATE TABLEjust delete all the rows without providing any additional information.