TRUNCATE TABLE – Wipe All Data, Keep the Table

(because sometimes you just want a fresh start)

Quick Syntax

TRUNCATE TABLE table_name;

You’re telling SQL:
“Clear out all the rows — but keep the table structure.”

No data left, but the columns, types, and table still exist.

Imagine your table looks like this:

id name age phone
1Olivia265550001234
2Mason245556712345
3Zoe305559083344
4Ethan215554421199
5Harper255552223344

Now you want to clear all the data but keep the table setup.
Maybe you’re starting a new batch of records or cleaning test data.

TRUNCATE the table

TRUNCATE TABLE friends;

Output:

Query OK, 0 rows affected

What’s left after?

SELECT * FROM friends;

Output:

id name age phone
empty table

The table is still there, still has all the same columns — but now it’s empty. Fresh as new.

TRUNCATE vs DELETE

Feature DELETE TRUNCATE
Deletes rows Yes Yes
Keeps structure Yes Yes
Slower Can be slow Fast (no logging)
Can use WHERE Yes No — all rows only
Auto-increment ID Continues count Often resets to 1

Recap

  • TRUNCATE clears all rows but keeps the table
  • Super fast and clean — but removes everything
  • You can’t filter — it’s all or nothing
  • Great for resetting test data or starting fresh

Want to know more about what kinds of data you can store in your tables? You can read more here:
More about SQL data types

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top