删除mysql中的主键
听起来很简单,但我似乎很难在 mysql 中的表上删除主键 - 有一个以 CompID 作为主键的表 CompanyList。它被用作数据库中其他几个表的外键。
我想保留 CompID 字段,但不希望它成为主键。
我尝试从 CompID 中删除主键,但收到错误。
错误:运行故障回复脚本时出错。详细信息如下。 错误 1050:表“CompanyList”已存在
为了实现此目的,我是否应该删除所有外键引用。
任何帮助将不胜感激。
Sounds simple but I seem to have a tough time in dropping a primary key on a table in mysql - Have a table CompanyList with CompID as the primary key. It is being used as a foreign key in a bunch couple of other tables in the database.
I want to retain the field CompID but I do not want it to be the primary key.
I tried removing the primary key from CompID but got the error.
ERROR: Error when running failback script. Details follow.
ERROR 1050: Table 'CompanyList' already exists
Should I drop all the foreign key references in order to achieve this.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您必须删除所有外键才能删除它们引用的主键。
Yes, you have to drop all FOREIGN KEYs to drop the PRIMARY KEY they reference.