Truncate (SQL)

Source: Wikipedia, the free encyclopedia.

In

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 SQL:2008
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 FROM mytable statement (without a WHERE clause). The following characteristics distinguish TRUNCATE TABLE from DELETE:

References

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