I am currently working on a personal project and i would like to be able to delete SQL and not have autoincrement still go from the last id it was
Asked
Active
Viewed 451 times
-2
-
`ALTER TABLE tablename AUTO_INCREMENT = 1` – Lukasz Szozda Dec 06 '15 at 16:24
-
Use `truncate table`. This will reset the auto increment id as well as removing the contents of the table. – Gordon Linoff Dec 06 '15 at 16:33
1 Answers
0
This is probably worth an answer.
delete from t
and
truncate table t
are very similar in that they both remove all rows from the the table t
. However, truncate table
has certain other features, such as:
- No logging, so it is faster.
- Resetting the auto-increment value.
- No invocation of triggers.
So, use it to empty your tables and remove all the rows.
The documentation discusses this.

Gordon Linoff
- 1,242,037
- 58
- 646
- 786