MySQL Forums
Forum List  »  Newbie

Re: Auto_Increment
Posted by: Phillip Ward
Date: April 04, 2018 05:12AM

Quote

Assume you have a table with an auto_increment primary key.

OK.

Quote

Assume you have 100 records in the table such that the highest primary key value is 100.

I would not assume that.

Values can be "skipped" because they are allocated by rows being added but the transactions creating those inserts are rolled back before completion. The Id values are not "released" or "reused".

Quote

Then assume that for whatever reason you delete that last record. When the next record is later added, will the primary key value of 100 be skipped or will it be repeated since the old record with 100 was deleted?

The value will not be reused. The next record would [probably] by 101.

Auto-Increment values are guaranteed to be unique but not to be sequential, nor should that matter to you in the slightest.

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
April 03, 2018 08:04AM
April 03, 2018 09:12AM
Re: Auto_Increment
April 04, 2018 05:12AM


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.