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

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.