How can I reset / restart the value of AUTO_INCREMENT
in Mysql
, without using TRUNCATE
?
In some cases, it is not possible to use TRUNCATE table
in some tables.
How can I reset / restart the value of AUTO_INCREMENT
in Mysql
, without using TRUNCATE
?
In some cases, it is not possible to use TRUNCATE table
in some tables.
Use ALTER TABLE
to do this.
You can "reset" a table as follows:
DELETE FROM tabela;
ALTER TABLE tabela AUTO_INCREMENT = 1;
You can also set another starting value for AUTO_INCREMENT
instead of 1
.
Example:
ALTER TABLE tabela AUTO_INCREMENT = 1000;