In SQL, the TRUNCATE TABLE statement is a data manipulation language (DML)[1] operation that deletes all rows of a table without causing a triggered action. 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
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:
TRUNCATE TABLE mytable
DELETE FROM mytable
WHERE
DELETE
TRUNCATE
ON DELETE
ON UPDATE
The SQL standard classifies TRUNCATE as a data change statement, synonymous with data manipulation (DML). This aligns with TRUNCATE being logically equivalent to an unconstrained DELETE operation.
However, some documents describe TRUNCATE as a data definition language (DDL) operation, because TRUNCATE may be seen as a combined DROP+CREATE operation.[2]
This database-related article is a stub. You can help Wikipedia by expanding it.
This programming-language-related article is a stub. You can help Wikipedia by expanding it.