Truncate (SQL) explained

In SQL, the TRUNCATE TABLE statement is a Data Manipulation Language (DML) operation that deletes all rows of a table without causing a triggered action.[1] The result of this operation quickly removes all data from a table, typically bypassing a number of integrity enforcing mechanisms. It was officially introduced in the standard, as the optional feature F200, "TRUNCATE TABLE statement".

TRUNCATE TABLE removes all rows from a table, but the table structure and its columns, constraints, indexes, and so on remain. To remove the table definition in addition to its data, use the DROP TABLE statement.

The TRUNCATE TABLE mytable statement is logically (though not physically) equivalent to the [[Delete (SQL)|DELETE]] FROM mytable statement (without a [[Where (SQL)|WHERE]] clause). The following characteristics distinguish TRUNCATE TABLE from DELETE:

Notes and References

  1. Web site: ISO/IEC 9075 Database languages SQL . iso.org . 4 June 2023 . ISO/IEC 9075 14.10.
  2. Web site: Description of the effects of nonlogged and minimally logged operations on transaction log backup and the restore process in SQL Server. Microsoft. December 2005.