How to add a primary key to a MySQL table?

前端 未结 10 1166
渐次进展
渐次进展 2020-11-29 18:53

This is what I tried but it fails:

alter table goods add column `id` int(10) unsigned primary AUTO_INCREMENT;

Does anyone have a tip?

10条回答
  •  天命终不由人
    2020-11-29 19:21

    Remove quotes to work properly...

    alter table goods add column id int(10) unsigned primary KEY AUTO_INCREMENT;
    

提交回复
热议问题