Jump to content

[SOLVED] Auto increment 1st available number?


mister2quick

Recommended Posts

I have a database set to auto increment whenever a new row is added.  Is it possible to to have the auto-increment field to auto-update when a row is deleted?  IE: when row 17 is deleted, row 18 becomes row 17, row 19 becomes row 18?  And when a new row is added it becomes row 19?

 

I'm fairly new to the scene, so any and all help is greatly appreciated!  If it means anything at all, i'm using XAMPP 1.7.0 with phpmyadmin.

 

Thanks!

The intent of an auto incrementing index is that it is a unique identifier.

 

Consider the case were two different people are making changes at the same time. One person deletes a row and adds a new one before the second person clicks on their form to delete a row. If the auto incrementing index gets reused, the second person just deleted the row that the first person added, not the row that they wanted to delete because it had already been deleted by the first person.

 

If you or your application expects no gaps in the auto incrementing index, you are attempting to use it for something that it is not intended to be used for.

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.