Auto Increment skipping numbers?

后端 未结 4 617
旧巷少年郎
旧巷少年郎 2020-12-03 14:21

Note: I\'m new to databases and PHP

I have an order column that is set to auto increment and unique.

In my P

4条回答
  •  误落风尘
    2020-12-03 14:59

    I know the question has been answered already.. But if you have deleted rows in the table before, mysql will remember the used ID/Number because typically your Auto increment is Unique.. So therefore will not create duplicate increments.. To reindex and increment from the current max ID/integer you could perform:

    ALTER TABLE TableName AUTO_INCREMENT=(SELECT max(order) + 1 FROM tablename)
    

提交回复
热议问题