Reorder AUTO_INCREMENT correctly

Asked

Viewed 33 times

-2

Hi,

I need to reorder the field AUTO_INCREMENT in the Mysql to stay in the correct sequence. Searching, I managed to do it but when I enter a new record, it gets the Id continued from the previous order. Examples:

BEFORE

Id’s: 1, 2, 4, 5, 7...

REORDERED

Id’s: 1, 2, 3, 4, 5...

AFTER NEW REGISTRATION

Id’s: 1, 2, 3, 4, 5, 8.

How do I reorder and continue correctly?

  • why not create a column codigo to control this?

  • What would be the correction in case of disorder?

  • If you do not have a field that can order, type date of registration or code, I believe you will have to do manual..

1 answer

0

Speak buddy, try to edit the registration code from 8 to 6 and then run this command:

ALTER TABLE AUTO_INCREMENT = 1

Browser other questions tagged

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