The SQL truncate TABLE statement is used to delete all records from an existing table. It performs the same function as a DELETE statement without a WHERE clause, and removes all rows from a table, but the structure of the table and its columns, constraints, indexes, etc. remain intact. To delete the table definition in addition to its data, use the DROP TABLE statement.
The TRUNCATE TABLE command is a data definition language (DDL) operation that marks extensions of a table for deallocation (empty for reuse).SQL Server stores data from a table on pages. The truncate command deletes rows by deallocating pages and makes an entry for page deallocation in the transaction log. It does not record the deletion of each row in the transaction log. To delete all records from the customer_data table, you can include the select query before and after the truncation operation. The TRUNCATE TABLE statement does not require confirmation at every step, but automatically triggers confirmation at the end of the statement execution.
As it is also a DDL statement, it does not allow for rollback or undo operations in many SQL databases. In summary, the SQL TRUNCATE TABLE command is used to delete complete data from an existing table. It removes all rows from a table, but the structure of the table and its columns, constraints, indexes, etc. To delete the table definition in addition to its data, use the DROP TABLE statement.