Auto Increment after delete in MySQL

后端 未结 17 2022
醉酒成梦
醉酒成梦 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:36

    You may think about making a trigger after delete so you can update the value of autoincrement and the ID value of all rows that does not look like what you wanted to see.

    So you can work with the same table and the auto increment will be fixed automaticaly whenever you delete a row the trigger will fix it.

提交回复
热议问题