#1025 - 将“./database/#sql-2e0f_1254ba7"重命名为“./database/table"时出错(错误号:150) [英] #1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150)

查看:15
本文介绍了#1025 - 将“./database/#sql-2e0f_1254ba7"重命名为“./database/table"时出错(错误号:150)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图向我的数据库中的一个表添加主键.现在它有一个这样的主键:

So I am trying to add a primary key to one of the tables in my database. Right now it has a primary key like this:

PRIMARY KEY (user_id, round_number)

其中 user_id 是外键.

Where user_id is a foreign key.

我正在尝试将其更改为:

I am trying to change it to this:

PRIMARY KEY (user_id, round_number, created_at)

我在 phpmyadmin 中通过单击表结构视图中的主键图标来执行此操作.

I am doing this in phpmyadmin by clicking on the primary key icon in the table structure view.

这是我得到的错误:

#1025 - Error on rename of './database/#sql-2e0f_1254ba7' to './database/table' (errno: 150)

它是一个带有 InnoDB 表引擎的 MySQL 数据库.

It is a MySQL database with InnoDB table engine.

推荐答案

可能有另一个表的外键引用了您要更改的主键.

There is probably another table with a foreign key referencing the primary key you are trying to change.

要找出导致错误的表,您可以运行 SHOW ENGINE INNODB STATUS 然后查看 LATEST FOREIGN KEY ERROR 部分.

To find out which table caused the error you can run SHOW ENGINE INNODB STATUS and then look at the LATEST FOREIGN KEY ERROR section.

这篇关于#1025 - 将“./database/#sql-2e0f_1254ba7"重命名为“./database/table"时出错(错误号:150)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆