Reorder / reset auto increment primary key

后端 未结 15 1409
北荒
北荒 2020-11-22 04:39

I have a MySQL table with an auto increment primary key. I deleted some rows in the middle of the table. Now I have, for example, something like this in the ID column: 12, 1

15条回答
  •  孤街浪徒
    2020-11-22 05:10

    You can also simply avoid using numeric IDs as Primary Key. You could use Country codes as primary id if the table holds countries information, or you could use permalinks, if it hold articles for example.

    You could also simply use a random, or an MD5 value. All this options have it's own benefits, specially on IT sec. numeric IDs are easy to enumerate.

提交回复
热议问题