How would I ensure that when something is deleted in a database the id of the records are changed so I get a continuous, consecutive collection of ids, e.g. I have a record with ID 1 and another record with ID 2 and another with ID 3, when 2 is deleted, how can I ensure that the ID of the record ‘3’ will now be ‘2’.
Share
You normally don’t, in particular if this is a primary key and even more so if it is used as a foreign key (then you will need to change it everywhere it is referenced).
Having “holes” in your table is not an operational issue at all.