The SQL truncate TABLE statement is a data definition language (DDL) command used to delete all records in a table. It performs the same function as a DELETE statement without a WHERE clause, quickly and using fewer system log and transaction resources. The TRUNCATE TABLE command removes data from a table, but not the table itself. It deletes all rows in a table or specified partitions of a table, without recording deletions of individual rows.
SQL Server stores data from a table on pages, and the truncate command deletes rows by deallocating pages and making an entry for page deallocation in the transaction log. It does not record the deletion of each row in the transaction log. The TRUNCATE () function is also used to truncate a number to the specified number of decimal places. It returns n with d truncated decimal places, or truncates from n to 0 decimal places if d is omitted.
If d is a negative number, it truncates the number from n to d digits on the left to the decimal point. MySQL, on the other hand, needs arguments n and d. In conclusion, the SQL TRUNCATE TABLE command is used to delete complete data from an existing table quickly and efficiently. The TRUNCATE () function is used to truncate a number to the specified number of decimal places.