修改、删除表时候提示MySQL Cannot delete or update a parent row: a foreign key constraint fails
作者:互联网
MySQL Cannot delete or update a parent row: a foreign key constraint fails
原因:外键关联
一下代码查询外键:
select
TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME
from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
where CONSTRAINT_SCHEMA ='数据库名称' AND
REFERENCED_TABLE_NAME = 表名称;
先解除外键即可。
文章来源:刘俊涛的博客 欢迎关注公众号、留言、评论,一起学习。
__________________________________________________________________________________
若有帮助到您,欢迎点击推荐,您的支持是对我坚持最好的肯定(*^_^*)
标签:fails,REFERENCED,NAME,parent,constraint,COLUMN,外键,MySQL,TABLE 来源: https://www.cnblogs.com/lovebing/p/13730193.html