gork4life Posted May 16, 2012 Share Posted May 16, 2012 I need help I'm with a table that primary keys auto-increments let's say we have five records listed with primary key as 1,2,3,4,5. What I want is when I delete lets say record 5, the next time I create a record I want it to be 5. Is this possible and is it recommended? Quote Link to comment Share on other sites More sharing options...
smerny Posted May 16, 2012 Share Posted May 16, 2012 not recommended, strongly recommend never doing anything like that record 5 could be referenced from other places, if you remove it or replace it, you will have a broken or incorrect reference Quote Link to comment Share on other sites More sharing options...
smoseley Posted May 16, 2012 Share Posted May 16, 2012 not recommended, strongly recommend never doing anything like that +1 Quote Link to comment Share on other sites More sharing options...
fenway Posted May 19, 2012 Share Posted May 19, 2012 Exactly -- you could have 2 references to '5'. Foreign key constraints will keep you from making this mistake. Quote Link to comment Share on other sites More sharing options...
gizmola Posted May 19, 2012 Share Posted May 19, 2012 I need help I'm with a table that primary keys auto-increments let's say we have five records listed with primary key as 1,2,3,4,5. What I want is when I delete lets say record 5, the next time I create a record I want it to be 5. Is this possible and is it recommended? As an idea, we could have an interesting discussion, but the fact is, that is not supported. Quote Link to comment Share on other sites More sharing options...
Barand Posted May 19, 2012 Share Posted May 19, 2012 On death row there is a particularly nasty character guilty of numerous murders. Having been a repeat offender all his life he has rather a large criminal records file, the ID of this file being his social security number. The guy is finally executed so his social security number is no longer required. By coincidence, just after he is executed, your child is born and, as this guy no longer needs his SSN, it is reallocated to your child. Your child, though completely innocent, now has a criminal record as long as your arm. A fictitious and extreme example but nonetheless a lesson in why you don't reallocate keys. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.