Jump to content

how to set auto_increment to fill in the lowest value


Zeradin

Recommended Posts

my website involves a lot of entries in the table to be deleted. is there a way to make the id field auto_increment to save new entries as the lowest available integer rather than +1 of the last one? Thanks.

There is, but there shouldn't be... it shouldn't matter to you, either, or you're using the ID field for something you're not supposed to be using it for

Link to comment
Share on other sites

I also had this notion when I was beginning toying with databases. But the reality is: auto_increment for database is like a grease for mechanisms. It makes the whole running smoothly, but it doesn't have to look good.

 

By recycling auto_increment values you're likely to fall into some trouble sooner or later, without any benefits whatsoever. On the other hand, it's extremely unlikely that you will run out of 'free' numbers. Just think a second: 32bit int has maximum value of 4294967296. You'd have to do 100 inserts a second 24/7/365 to reach this number in something like 16 months...

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.