MySQL Tutorial

Define MySQL

MySQL Create Database

MySQL Create Table

MySQL Constraints

MySQL Case Sensitivity

MySQL Insert

MySQL Select

MySQL Data Types

MySQL OrderBy


MySQL Distinct

MySQL Update

MySQL Delete

MySQL Truncate

MySQL Drop

MySQL Alter

MySQL Join

MySQL Aggregate Function

MySQL String Function

MySQL Date Function

Page Stats

Visitor: 231

MySQL Truncate Table

Logically, TRUNCATE TABLE is similar to the DELETE statement with no WHERE clause. The TRUNCATE TABLE removes all rows from a table more quickly than a DELETE statement.

TRUNCATE TABLE table_name;


Differences between DELETE and TRUNCATE TABLE are:

  1. TRUNCATE TABLE statement drop and re-create the table in such a way that any auto-increment value is reset to its start value which is generally 1.
  2. DELETE lets you filter which rows to be deleted based upon an optional WHERE clause, whereas TRUNCATE TABLE doesn't support WHERE clause it just removes all rows.
  3. TRUNCATE TABLE is faster and uses fewer system resources than DELETE, because DELETE scans the table to generate a count of rows that were affected then delete the rows one by one and records an entry in the database log for each deleted row, while TRUNCATE TABLE just delete all the rows without providing any additional information.
Updated: 24-Aug-21