添加表时MySQL“错误1005”

时间:2022-12-24 23:14:50

I've recently been working with a MySQL database, and using MySQL workbench to design the Database.

我最近一直在使用MySQL数据库,并使用MySQL工作台来设计数据库。

When I use the export to SQL function, so I can actually get the layout in to the Database, I get:

当我使用导出到SQL函数时,我实际上可以将布局放到数据库中,我得到:

"Error 1005: Cannot create table"

“错误1005:无法创建表”

This appears to be related to Foreign Keys in the create table statement.

这似乎与create table语句中的Foreign Keys有关。

Does anybody have a work around for this that doesn't involve taking the constraints out and putting them back in later? That's a less than ideal solution given the size of the database.

有没有人为此解决这个问题,而不是将限制因素排除在外并将它们放回去?考虑到数据库的大小,这是一个不太理想的解决方案。

2 个解决方案

#1


7  

When you get this (and other errors out of the InnoDB engine) issue:

当你得到这个(和InnoDB引擎的其他错误)问题:

SHOW ENGINE INNODB STATUS;

It will give a more detailed reason why the operation couldn't be completed. Make sure to run that from something that'll allow you to scroll or copy the data, as the response is quite long.

它将更详细地说明无法完成操作的原因。确保从允许您滚动或复制数据的内容中运行该内容,因为响应时间很长。

#2


1  

I ran into this situation recently when I attempted (in InnoDB tables) to make a foreign key reference to a column that had a different data type.

最近,当我尝试(在InnoDB表中)对具有不同数据类型的列进行外键引用时,我遇到了这种情况。

MySQL 5.1 Documentation

MySQL 5.1文档

#1


7  

When you get this (and other errors out of the InnoDB engine) issue:

当你得到这个(和InnoDB引擎的其他错误)问题:

SHOW ENGINE INNODB STATUS;

It will give a more detailed reason why the operation couldn't be completed. Make sure to run that from something that'll allow you to scroll or copy the data, as the response is quite long.

它将更详细地说明无法完成操作的原因。确保从允许您滚动或复制数据的内容中运行该内容,因为响应时间很长。

#2


1  

I ran into this situation recently when I attempted (in InnoDB tables) to make a foreign key reference to a column that had a different data type.

最近,当我尝试(在InnoDB表中)对具有不同数据类型的列进行外键引用时,我遇到了这种情况。

MySQL 5.1 Documentation

MySQL 5.1文档