爲已存在數據的表加主鍵

alter table `表格名` add column `列名` int not null auto_increment primary key comment '主鍵' first;    

上面語句表示給某個表格添加一個自動增長的主鍵字段,並且將該字段放在第一列。

如果你想放到其他列後面,可以將上面sql語句中的 first 換成  after `已經有的列名


alter table `customfield_person_value` add column `ID` int not null auto_increment   primary key comment '主鍵'    first;   
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章