0

Possible Duplicate:
How to fill in the “holes” in auto-incremenet fields?

I have a problem when deleting a user in my database, the ID column always skips and just continues to increment, even if there are skipped numbers inside the column.

For ex:

+---------+----------+---------+
|   ID    |  first   |   last  |
+---------+----------+---------+
|    1    |    a     |    a    |
+---------+----------+---------+
|    3    |    c     |    c    |
+---------+----------+---------+
|    4    |    d     |    d    |
+---------+----------+---------+
|    5    |    e     |    e    |
+---------+----------+---------+
|    7    |    g     |    g    |
+---------+----------+---------+
|    9    |    i     |    i    |
+---------+----------+---------+

Is there anyway to automatically fill in the gap on my ID column when creating a new user? Or just adjust the remaining users on the list to fill in the gap?

Dharman
  • 30,962
  • 25
  • 85
  • 135
telexper
  • 2,381
  • 8
  • 37
  • 66

1 Answers1

0

That's just how auto increment columns work. The gaps won't cause any issues with performance or anything. The only way that the gaps could cause an issue is if you frequently delete rows and get close to the column's max value (probably 4 billion). If you were to change the ids to fll in the gaps, you would have to make sure every reference to the ID is updated, which is usually not worth the trouble. In summary, you can ignore the gaps.

G-Nugget
  • 8,666
  • 1
  • 24
  • 31