1. 程式人生 > 其它 >mysql刪除表時,提示“mysql Cannot delete or update a parent row: a foreign key constraint fails”

mysql刪除表時,提示“mysql Cannot delete or update a parent row: a foreign key constraint fails”

技術標籤:資料庫技術mysql

刪除表A的時提示提示“mysql Cannot delete or update a parent row: a foreign key constraint fails”,表示A表與其他表存在參照完整性約束。
解決方法1:
關閉約束檢查 刪除約束檢查 開啟約束檢查;示例程式碼如下:

SET foreign_key_checks = 0; 
drop table A;
SET foreign_key_checks = 1; 

解決方法2:
點選table,找到約束名,刪除約束,然後再刪除表。

在這裡插入圖片描述

ALTER TABLE tab_name DROP FOREIGN
KEY fk_name drop table tbill