somejkuser
somejkuser

Reputation: 9040

MySQL Resetting the index count to 0

I need to reset my table counter back to 0 - is there a MySQL command for this?

Upvotes: 28

Views: 28678

Answers (2)

Peter Bailey
Peter Bailey

Reputation: 105916

You can also use the TRUNCATE statement. It will remove all the data and reset the auto increment.

TRUNCATE TABLE [TableName];

Is the same as

DELETE * FROM [TableName];
ALTER TABLE [TableName] AUTO_INCREMENT = 0;

Upvotes: 19

Andomar
Andomar

Reputation: 238246

That's easy:

ALTER TABLE tablename AUTO_INCREMENT=0;

Upvotes: 55

Related Questions