刪除外連接老是報錯152,這個怎么解決
威她命willian陳威
2016-09-13 12:06:25
TA貢獻89條經驗 獲得超53個贊
檢查一下你的外健名有沒有寫錯 曾經這是MySQL的一個bug,但是現在只是MySQL的一個不友好的地方。 ????? 例子如下: ????? ALTER TABLE ruler.test2child DROP FOREIGN KEY test; ????? ERROR 1025 : Error on rename of './ruler/test2child' to './ruler/#sql2-298-8f' (errno: ????? 152) ????? 這里并不是不能刪除外鍵,而是使用了錯誤的外鍵名稱,但是MySQL報的錯實在離譜。 ????? 正確的錯誤信息要如下查詢才能知道: ????show innodb status; ????? ------------------------ ????? LATEST FOREIGN KEY ERROR ????? ------------------------ ????? 071222 20:48:26 Error in dropping of a foreign key constraint of table ????? "ruler"."test2child", ????? in SQL command ????? ALTER TABLE ruler.test2child DROP FOREIGN KEY test ????? Cannot find a constraint with the given id "test". ? ? ? ? ? ? ? ? ? ? ? ? ? ?
舉報