# `TRUNCATE` Statement

__*TRUNCATE*__

+ The **`TRUNCATE`** statement deletes all rows in the table
+ It resets **`AUTO_INCREMENT`** to the starting value
+ Unlike **`DELETE`**, it's `DDL`, not `DML`, meaning it isn't transactional and cannot be rolled back
+ Logically equivalent to execute in order: **`DROP TABLE`**, **`CREATE TABLE`**
+ It may be possible to undo using **`FLASHBACK TABLE`** statement

```
~!@// Syntax@!~
TRUNCATE [TABLE] {table_name};

~!@// Example@!~
tidb> SELECT COUNT(*) FROM universe.moons;
+----------+
| COUNT(*) |
+----------+
|       ~!@28@!~ |
+----------+
1 row in set (0.01 sec)

tidb> ~!@TRUNCATE universe.moons;@!~
~!@Query OK, 0 rows affected@!~ (0.63 sec)

tidb> SELECT COUNT(*) FROM universe.moons;
+----------+
| COUNT(*) |
+----------+
|        ~!@0@!~ |
+----------+
1 row in set (0.01 sec)
```

------------------------------------------------------------
The TRUNCATE statement removes all data from a table in a non-transactional manner. The TRUNCATE statement can be considered semantically identical to the DROP TABLE + CREATE TABLE combination.

Both TRUNCATE TABLE table_name and TRUNCATE table_name are valid syntax.
