更改表错误
有人可以向我解释为什么我收到以下错误吗?
我想使用以下语法将 mysql 表中的“exerciseID”列重命名为“ID”。
ALTER TABLE `exercises` CHANGE `exerciseID` `ID` INT( 11 ) NOT NULL AUTO_INCREMENT
但是我收到以下错误:
MySQL said:
#1025 - Error on rename of './balance/#sql-de_110e' to './balance/exercises' (errno: 150)
任何建议将不胜感激
Can someone explain to me why I am receiving the following error?
I want to rename the column "exerciseID" to "ID" in a mysql table using the following syntax.
ALTER TABLE `exercises` CHANGE `exerciseID` `ID` INT( 11 ) NOT NULL AUTO_INCREMENT
However I receive the following error:
MySQL said:
#1025 - Error on rename of './balance/#sql-de_110e' to './balance/exercises' (errno: 150)
Any suggestions would be much appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会检查您是否有对该列的任何外键引用。如果是这样,您可能需要删除为该列定义的外关系,然后重命名,然后使用新的列名称将外键关系放回原处。
我认为 MySQL 陷入了这样一个事实:当你重命名时,FK 关系不再有效,并且会抛出错误。
编辑:已确认
FK 在 MySQL 中重命名
您将需要执行以下操作:
I would check to see if you have any foreign key references to that column. If so, you may need to remove the foreign relationships that you have defined for that column, then rename, then place your foreign key relationships back in place with the new column name.
I think MySQL is getting hung up on the fact that when you rename, the FK relationships are no longer valid and it is throwing an error.
EDIT: Confirmed
FK Rename in MySQL
You will need to do something like this:
我认为这可能是一个多步骤的过程。
i think it might be a multi step process.
只是在谷歌中进行了快速搜索,看起来您正在引用外键中的列 - 这阻止了重命名。
恐怕我不确定你会如何解决这个问题,因为我没有在 MySQL 中使用过那么多外键
just having a quick search in google, and it looks like you are referencing the column in a foreign key - which is preventing the rename.
afraid i'm not sure how you'd resolve the problem, as I haven't used foreign keys in MySQL all that much