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

查看:73
本文介绍了#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天全站免登陆