官方的说明:
1005 (ER_CANT_CREATE_TABLE)Cannot create table. If the error message refers to error 150, table creation failed because a foreign key constraint was not correctly formed. If the error message refers to error –1, table creation probably failed because the table includes a column name that matched the name of an internal
InnoDBtable.
我犯的错误是,把某列设为非空,同时又在为该列增加外键约束的时候添加了 ON DELETE SET NULL。
其实我是用备份出来的.sql,重建数据库时发生这个问题的。这说明如果先为某列添加外键约束 ON DELETE SET NULL,之后再将该列设为非空,系统并不会发现这个问题。然后如果ON DELETE的话,数据库应该就会出现某种错误。
Thanks to: http://dev.mysql.com/doc/refman/5.0/en/innodb-error-codes.html
本文介绍了一个关于MySQL数据库中,在设置列属性为非空的同时添加外键约束ONDELETESETNULL时出现的错误1005。通过实例演示了如何避免这类问题,并解释了错误产生的原因。
1万+

被折叠的 条评论
为什么被折叠?



