RapsFan1981
RapsFan1981

Reputation: 1197

phpMyAdmin - autoincrementing ID

Quick question regarding phpMyAdmin and autoincrementing. If I add a product and it is assigned id 1, then I delete it before adding another, the next one is given the id 2 even though I deleted id 1. I hope this makes sense.

Does this matter?

Upvotes: 0

Views: 146

Answers (3)

mgabor
mgabor

Reputation: 963

Its not the way it works. The auto increment value is stored in a variable, and it only adds one to that, instead of checking the largest one and adding one to that. Its the normal behavior, it looks messy but it works fine.

Upvotes: 1

JHarnach
JHarnach

Reputation: 4034

Consider the example where you had 1000 rows, and deleted the row ID=1. Would you expect the next entry to be given an ID of 1001 ? or 1 ?

This is working as intended, though if you absolutely must, you can manually set the value just as you would any other column in MySQL.

Upvotes: 0

Konerak
Konerak

Reputation: 39763

No, this is normal (My)SQL behaviour.

Upvotes: 1

Related Questions