ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`meiduo`.`
在MySQL中删除一张表或一条数据的时候,出现
这是因为MySQL中设置了foreign key关联,造成无法更新或删除数据。可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况。
我们可以使用
SET FOREIGN_KEY_CHECKS=0;
来禁用外键约束.
之后再用
SET FOREIGN_KEY_CHECKS=1;
来启动外键约束.
查看当前FOREIGN_KEY_CHECKS的值可用如下命令
SELECT @@FOREIGN_KEY_CHECKS;
ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`meiduo`.`相关推荐
- 表删除时 Cannot delete or update a parent row: a foreign key constraint fails 异常处理
有两张表,结构如下: t_item: t_bid: id int id int name varchar name varchar item_id int 其中表t_item的主键id是表t_bid的 ...
- 4 Flask开发进阶:记下一次级联删除的报错:Cannot delete or update a parent row: a foreign key constraint fails
中间表 class Permission(object):LOGIN = 0x01EDITOR = 0x02OPERATOR = 0x04ADMINISTER = 0xffPERMISSION_MAP ...
- Mysql报错 Cannot delete or update a parent row: a foreign key constraint fails
mysql数据库中使用delete语句删除表中的一条信息时,报错:1451 - Cannot delete or update a parent row: a foreign key constrai ...
- 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 问题的解决办法 参考文章: (1 ...
- 解决Cannot delete or update a parent row: a foreign key constraint fails的mysql报错
1 问题 删除有外键关联的数据或者表的时候,mysql出现报错: Cannot delete or update a parent row: a foreign key constraint fail ...
- MySQL遇到错误:1217 - Cannot delete or update a parent row: a foreign key constraint fails
遇到问题 今天在准备"删库跑路"的时候,有的数据表再删除的时候报了以下错误: 1217 - Cannot delete or update a parent row: a fore ...
- MySQL删除表:Cannot delete or update a parent row: a foreign key constraint fails。
MySQL库中有俩表,table1和table2,相互关联,在删除表的时候出错: Cannot delete or update a parent row: a foreign key constra ...
- 删除有外键关联的表报错,Cannot delete or update a parent row: a foreign key constraint fails
解决办法: SET foreign_key_checks = 0; //先设置取消外键检查 drop table portal_user; SET foreign_key_checks = 1; // ...
- 删除订单时报错Cannot delete or update a parent row: a foreign key constraint fails (`jxc`.`t_purchase_list_
删除数据的id与其他表的id有外键关联,所以关联的数据也要删除 注:先删主键,再删外键.
最新文章
- manage.py命令
- Android开发之发送邮件功能的实现(源代码分享)
- PathComposePathEffectView 使用
- 指针数组 与 数组指针 的分析
- hdu 5155(DP+排列组合)
- 调用AutoCAD的内置对话框
- 一部论述修养人生处世出世的集录_读《菜根谭》,人生本是修心的过程
- [redis] Jedis 与 ShardedJedis 设计
- IDEA新项目代码上传到gitlab远程仓库
- sysoper在oracle是什么意思,oracle用户 sysdba 与system,sysoper的区别
- 智能锁行业安全分析报告
- 一周信创舆情观察(12.13~12.19)
- 能编辑pdf文件的软件
- ss1111111111111111111111111111111111111111
- LED恒流驱动芯片NU9910用于LED舞台灯光驱动控制芯片拼对拼SMD802
- C语言 数组 冒泡排序法
- 给客户一个“无法拒绝”的SaaS?——6年三个SaaS项目后的感触
- 微信内部浏览器打开网页时提示外部浏览器打开 升级版
- python进阶day4
- python polygon_在Python中将Multipolygon转换为Polygon - python