Problem with auto-incremented “id” column

前端 未结 6 2189
别跟我提以往
别跟我提以往 2021-01-06 01:26

My db table looks like this pic. http://prntscr.com/22z1n

Recently I\'ve created delete.php page. it works properly but when i deleted 21th user next registered use

6条回答
  •  猫巷女王i
    2021-01-06 02:13

    It's not a good practice to reset auto_increment value, but if you really need to do it, so you can:

    ALTER TABLE mytable AUTO_INCREMENT = 1;
    

    Run this query after every delete. Auto_increment value will not be set to 1, this will set the lowest possible value automatically.

提交回复
热议问题