#1025 - Error on rename of #39;./database/#sql-2e0f_1254ba7#39; to #39;./database/table#39; (errno: 150)(#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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:#1025 - 将“./database/#sql-2e0f_1254ba7"重命名为“./database/table"时出错(错误号:150)


基础教程推荐
- 带更新的 sqlite CTE 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01