Auto Increment after delete in MySQL

后端 未结 17 2010
醉酒成梦
醉酒成梦 2020-11-22 09:50

I have a MySQL table with a primary key field that has AUTO_INCREMENT on. After reading other posts on here I\'ve noticed people with the same problem and with varied answer

17条回答
  •  时光取名叫无心
    2020-11-22 10:22

    What you're trying to do sounds dangerous, as that's not the intended use of AUTO_INCREMENT.

    If you really want to find the lowest unused key value, don't use AUTO_INCREMENT at all, and manage your keys manually. However, this is NOT a recommended practice.

    Take a step back and ask "why you need to recycle key values?" Do unsigned INT (or BIGINT) not provide a large enough key space?

    Are you really going to have more than 18,446,744,073,709,551,615 unique records over the course of your application's lifetime?

提交回复
热议问题