How to reset the auto_increment value (NO TRUNCATE)?

0

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.

    
asked by anonymous 24.08.2015 / 14:38

1 answer

1

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;
    
24.08.2015 / 14:38