TRUNCATE TABLE Syntax

In some cases, you want to delete all table data in a fast way and reset all auto increment columns. MySQL provides TRUNCATE table statement to allow you to do so. The SQL TRUNCATE statement is as follows:

TRUNCATE TABLE table_name

There are some points you should remember before using TRUNCATE TABLE statement:

  • TRUNCATE TABLE statement drops table and recreates it therefore it is much faster than DELETE TABLE statement. However it is not transaction-safe.
  • The number of deleted rows is not returned like SQL DELETE TABLE statement.
  • ON DELETE triggers are not invoked because TRUNCATE does not use DELETE statement.
TRUNCATE TABLE emp_table;

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.