这是我尝试过但失败的方法:
This is what I tried but it fails:
alter table goods add column `id` int(10) unsigned primary AUTO_INCREMENT;
有人给个提示吗?
添加列后,可以随时添加主键:
After adding the column, you can always add the primary key:
ALTER TABLE 商品ADD PRIMARY KEY(id)
至于为什么你的脚本不起作用,你需要指定PRIMARY KEY
,而不仅仅是PRIMARY
这个词:
As to why your script wasn't working, you need to specify PRIMARY KEY
, not just the word PRIMARY
:
alter table goods add column `id` int(10) unsigned primary KEY AUTO_INCREMENT;
这篇关于如何向 MySQL 表添加主键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!