Query to Re-index Primary Key of MySQL Database

前端 未结 3 1162
没有蜡笔的小新
没有蜡笔的小新 2020-12-23 21:44

I\'ve got a table in MySQL that has a Primary Key Column.

Lets say:

ID | Value
1  | One
2  | Two
6  | Three
8  | Four
9  | Five

How

3条回答
  •  温柔的废话
    2020-12-23 22:25

    Seems to me you have two options.

    1) create a new table and copy the existing data over.

    2) add another autoincrement field to the existing table, then delete the original column.

    ALTER TABLE tableName ADD NewIdn INT NOT NULL AUTO_INCREMENT KEY
    

提交回复
热议问题