How to zero the phpmyadmin auto-increment?

0

How do I reset the PHPMyadmin auto increment? Have you tried?

ALTER TABLE 'table_name' AUTO_INCREMENT=1

But it did not work

    
asked by anonymous 05.10.2015 / 19:55

2 answers

3

Your problem (and you NOT is alone) is a simple OCD due to deleted records. The recommendation is always not to worry about the voids that MySQL ends up leaving because the id column was not meant to be human readable.

In a system timeline, when a primary key is deleted, you can cause referential access to be broken automatically (System tells you that the 237 record no longer exists). If you fill this space with a different registry, you may end up having more issues than solutions.

The command you are executing does exactly the following

SELECT (MAX(id)+1) INTO @var FROM table;
ALTER TABLE 'table' AUTO_INCREMENT = @var;

That is, if your database has register 1 and then 15, the command that searches for max (id) + 1 will return 16, setting its auto increment to 16.

    
10.01.2016 / 13:00
2

Remember to delete all records from the table before using the commands that you tried.

ALTER TABLE tabela AUTO_INCREMENT = 1

You can use the PHPMyAdmin panel, select the table and then the Operações menu, just change in the Opções da tabela > AUTO_INCREMENT settings

    
05.10.2015 / 20:03