开发者

phpMyAdmin - autoincrementing ID

开发者 https://www.devze.com 2023-03-31 07:16 出处:网络
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.

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 th开发者_如何学编程is makes sense.

Does this matter?


No, this is normal (My)SQL behaviour.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号