Re: deleted primary key can't be reused? [message #181843 is a reply to message #181827] |
Wed, 12 June 2013 04:46 |
gordonb.ps993
Messages: 1 Registered: June 2013
Karma:
|
Junior Member |
|
|
> Entered 100 items into 2 columns each.
> Deleted 2.
Which two? What were their primary keys?
> Upon entering new record using id of 98, no can do.
> The next new record number becomes 101.
> "Duplicate key error" is issued.
Assuming the records you deleted had primary keys 42 and 86, this
is correct.
If you deleted record 98, you should be able to re-insert it.
> How do I take back the deleted key number so I can use it again?
You want *all* the records renumbered? I'd really hate it if banks
did that with account numbers, so which account is mine keeps
changing, and I keep having to have checks reprinted. Other tables
are likely to refer to records in this table by its primary key.
If you keep changing that, you get a mess. When is that useful?
I can think of plenty of business circumstances where it would be
a crime.
> No, I do not mean the data that is in the record.
> To me, once a record is deleted, the key index should reflect that the
> record no longer exists, so the key index should be -1 of what it was.
> Not continue its esistance.
In other words, if the primary key for a record is "Mary Contrary",
and you delete that, and the next record is "Michael Jackson", the
primary key for that record should now become "Mary Contrary"?
Primary keys are not, in general, supposed to change. That may not
correspond well to real-world reality. Account numbers may have
to change when banks merge and there are now duplicate account
numbers for the merged bank. Names (which make poor primary keys)
may change on marriage, adoption, etc. If you want something in
an order, add a column for the attribute you are sorting on (say,
song sales) and use ORDER BY.
|
|
|