#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)


- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 更改自动增量起始编号? 2021-01-01