Jump to content

clear out empty registry between ID's


criostage

Recommended Posts

Hi, i know this ain tan "BIG" question but ever since i started to play with php and mysql i noticed this. while testing values etc ... every time i delete an registry and re-add it later the id (as auto incremental) will add the registry normaly but will leave an "blank" id between 2 entries for example:

 

id  name     profession
1   john      programmer
2   mario    plummer
5   Samus  Bounty Hunter

 

Is there anyway to fill up the gaps or remove them? are these gaps "harmfull" to the database search's? thanks in advance

Link to comment
Share on other sites

These gaps are not harmfull, they are there for a good reason.  Auto_Inc is normaly only used for indexed keys.  As such the number is relative to an indexed postion within the table.  Each new row added to the table will get an indexed postion after the last row that was added, even if there have been other rows that have been deleted in between times.  The database is perfectly happy with these missing rows, otherwise I imagine you would be forced to re-index every time deleted a row.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.