mysql錯誤:ERROR 1005 Can't creat table `table_name`

官方的說明:

  • 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 InnoDB table.

我犯的錯誤是,把某列設爲非空,同時又在爲該列增加外鍵約束的時候添加了 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章