TRUNCATE TABLE: Remove all data from a table but retain its structure

3/5/2024
All Articles

#TRUNCATE TABLE: Remove all data from a table but retain its structure

TRUNCATE TABLE: Remove all data from a table but retain its structure

TRUNCATE table in Sql

Because TRUNCATE TABLE only dealslocates the data pages the table uses—without noting specific row deletions—it is significantly faster.

TRUNCATE TABLE table_name;

Just replace table_name with the name of the table you want to truncate. Be careful when using TRUNCATE TABLE because it removes all data from the specified table and cannot be undone. Additionally, it may reset any auto-incremented primary key columns back to their starting values.

Article