2011-11-16 81 views
0

如果我有3個表讓我們說,table1,table2和table3。MySQL外鍵錯誤1025

table1: userID is a primary key. 
table2: userID is a foreign key to table1. 
table3: I can't get userID to be a foreign key to table 1? 

ERROR 1025: Error on rename of.... (errno: 152) 

問題是什麼?用戶ID都是INT和使用的是InnoDB所有表...

+2

請顯示您嘗試使用的CREATE TABLE語句。 –

+1

請發表'show create table table1'的輸出和table2和table3的相同 – Lars

+0

我想到了 - 外鍵名稱在其他表格中似乎不能相同。 – Michael

回答

0

嘗試建立類似

create table table3(a int not null, foreign key(a) references table1 (a)) 

你的表應該可以正常工作。

此外,嘗試SHOW ENGINE INNODB STATUS你會得到更多的信息,哪裏出問題了。