criostage Posted September 20, 2011 Share Posted September 20, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/247515-clear-out-empty-registry-between-ids/ Share on other sites More sharing options...
Muddy_Funster Posted September 20, 2011 Share Posted September 20, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247515-clear-out-empty-registry-between-ids/#findComment-1271029 Share on other sites More sharing options...
fenway Posted September 20, 2011 Share Posted September 20, 2011 Never change an auto-incremented value -- EVER. Quote Link to comment https://forums.phpfreaks.com/topic/247515-clear-out-empty-registry-between-ids/#findComment-1271144 Share on other sites More sharing options...
criostage Posted September 21, 2011 Author Share Posted September 21, 2011 Thank you for the replies =) Quote Link to comment https://forums.phpfreaks.com/topic/247515-clear-out-empty-registry-between-ids/#findComment-1271298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.