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!

Link to comment
Share on other sites

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.

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.