How to reset the auto_increment value (NO TRUNCATE)?

Asked

Viewed 522 times

0

How can I reset/reset the value of AUTO_INCREMENT in the Mysql, without the use of TRUNCATE?

For in some cases it is not possible to use TRUNCATE table in some tables.

1 answer

1


Use the ALTER TABLE to do this.

It is possible to "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;
  • I’m glad you found the solution on your own! :)

  • 1

    I did not find the solution alone. In the OS we have an option where it is allowed to ask the question and, at the same time, post the answer. This is useful when you know something that may be important to someone else (note that the publication of the answer and the question have the same time)

  • see if this is useful to you as well, maybe you can help this person: http://answall.com/questions/5415/auto-incremento-id-valor/5421#5421

Browser other questions tagged

You are not signed in. Login or sign up in order to post.