删除mysql中的主键

发布于 2024-12-05 07:58:56 字数 261 浏览 4 评论 0原文

听起来很简单,但我似乎很难在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愁以何悠 2024-12-12 07:58:56

是的,您必须删除所有外键才能删除它们引用的主键。

Yes, you have to drop all FOREIGN KEYs to drop the PRIMARY KEY they reference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文