0

I have this database table where I insert multiple results during 1 action. In php I have a submit button when pressed, inserts 1-50 rows(depending on the user input). I've got a foreign key in this table which has the same value on the rows inserted during that action(so when the primary key connected to the foreign key gets deleted, the 1-50 rows will be deleted as well). Now I've got an Auto Increment in my table and during testing, I find out that the ID's are somewhat like this: 1,2,3,200,249,460,670. So like huge differences between the ID's. Whenever I would create a new row, it will get the ID 671. I feel like it would be better if the ID would just get 4 in this case. Is there any way of doing this automatically and not typing ALTER TABLE users AUTO_INCREMENT=4; manually? If so, are there any advantages/disadvantages?

3
  • @ypercube yeah that's it. Didn't know how people would phrase this question so I couldn't check if it already existed but this is exactly what I was looking for. Thank you.
    – Loko
    Mar 2, 2015 at 14:43
  • In short, there are lots of different reasons why gaps appear in an auto-generated sequence. You just let them as they are and not worry at all. INT type goes up to 4 billion values. Mar 2, 2015 at 14:45
  • @ypercube Yeah that's what I figured from the answer of the question. Thanks alot though
    – Loko
    Mar 2, 2015 at 14:47

0

Browse other questions tagged or ask your own question.