user569261
user569261

Reputation: 29

auto number problem

I have a question about the auto number, for example, I insert a record into the field "Id" in table "products". I input 3 fields "id" is 1.2, and 3. when I remove fied into 3, then I input the updated field again is 4, not 3. how so recorded is 3 instead of 4

Upvotes: 0

Views: 133

Answers (2)

Hoàng Long
Hoàng Long

Reputation: 10848

You may run the query: ALTER TABLE tablename AUTO_INCREMENT = 1

That will reset the beginning position of Auto-increment, hence when you insert the record again, it will take id 3.

You may find this link useful. It's very short and coherent.

Upvotes: 0

Pekka
Pekka

Reputation: 449485

This is by design. An identifier that has been used once must never, ever be used for another record. It could cause data corruption issues if there are relationships between tables - records could suddenly be pointing to a completely unrelated record in the original table.

Reference: 3.6.9. Using AUTO_INCREMENT

Upvotes: 7

Related Questions