In SQL, the truncate TABLE statement is a data definition language (DDL) operation that marks extensions of a table for deallocation (empty for reuse). This operation quickly removes all data from a table and generally ignores a number of integrity enforcement mechanisms. It performs the same function as a DELETE statement without a WHERE clause. SQL Truncate is a data definition language (DDL) command that deletes all rows in a table by unallocating the pages that are used to store table data.
The TRUNCATE TABLE statement deletes all rows from a table, but the structure of the table and its columns, constraints, indexes, and so on remain intact. To delete the table definition in addition to its data, you can use the DROP TABLE statement. Deleting rows with the TRUNCATE statement can be faster than deleting all rows with the DELETE statement, especially if the table has many triggers, indexes, and other dependencies. However, we must keep in mind that TRUNCATE TABLE statements may not be undone in many SQL databases.
For a domain index, this instruction invokes the appropriate truncation routine to truncate the domain index data. Logically, TRUNCATE TABLE is similar to a DELETE statement that deletes all rows or a sequence of DROP TABLE and CREATE TABLE statements. Deleting rows with the TRUNCATE statement can be more efficient than deleting and re-creating a table. In the following figure we can see that the TRUNCATE TABLE statement deleted all records from the client table. After executing a TRUNCATE statement on an existing table, the table becomes empty and therefore does not contain any row records.
As it is also a DDL statement, the TRUNCATE table statement does not require confirmation at every step, but automatically triggers confirmation at the end of the statement execution. In the above images we can see that the DROP TABLE statement is faster than the TRUNCATE TABLE statement in SQL.