MySQL Forums
Forum List  »  Newbie

Auto Increment Primary Key - Reuse of Primary Key?
Posted by: Michael John
Date: March 24, 2016 09:43AM

A number of my tables on a developmental database use auto incremented Primary Keys (IDs). Sometimes a record needs to be deleted – an action which leaves a gap. What I am unclear of is if the Primary Key is ever reused. I have found that if the last record added is deleted it is. This was discovered when someone testing the software asked for the Client record they had just added to be deleted. The next Client was allocated the same Primary Key which then linked to other (inappropriate) data. Is the last one allocated the only one reallocated or could the RDBMS fill the 'holes'. If this is the case I will need to cascade through the tables deleting any associated records in other tables immediately rather than wait for the weekly 'clean up' programme to run.

Many thanks...

Options: ReplyQuote


Subject
Written By
Posted
Auto Increment Primary Key - Reuse of Primary Key?
March 24, 2016 09:43AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.