Cannot delete or update a parent row: a foreign key constraint fails解决方法
来源:互联网 发布:linux服务器安全策略 编辑:程序博客网 时间:2024/05/21 17:12
我在使用delete from table语句清空一个表数据时,报错 Cannot delete or update a parent row: a foreign key constraint fails。
先把我的数据库贴出来。
tb_device表
tb_device_status_now表
正题:
最开始我直接清空tb_device,报错。看数据库发现tb_device_status_now中的字段与其外键关联所以不能清空。所以改为先清空tb_device_status_now表,再清空tb_device。结果发现还是报错!再看数据库,发现tb_device表中dev_master字段与dev_id字段也是外键关联。。。。
所以要先清空dev_master字段,才能清空tb_device整张表。
清空某字段数据的sql语句:update table set column=null
最后我的删除顺序:
0 0
- Cannot delete or update a parent row: a foreign key constraint fails解决方法
- 级联删除报Cannot delete or update a parent row: a foreign key constraint fails解决方法
- 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 "
- jbpm Cannot delete or update a parent row: a foreign key constraint fails
- MySQL错误号1451-Cannot delete or update a parent row: a foreign key constraint fails
- 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
- #1451 - Cannot delete or update a parent row: a foreign key constraint fails 问题的解决办法
- Cannot delete or update a parent row: a foreign key constraint fails
- jbpm4 jbpm4_execution “Cannot delete or update a parent row: a foreign key constraint fails” 异常解决
- ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails...问题解决
- Cannot delete or update a parent row: a foreign key constraint fails
- 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
- 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
- [MySQL]MYSQL: Cannot delete or update a parent row: a foreign key constraint fails
- (hdu step 9.1.2)Doing Homework again(贪心——有n份作业,每份作业都有一定的完成时间及没有完成时需要付出的代价,求最小代价)
- EventBus的学习与使用
- Android MediaPlayer播放异常问题汇总
- sqlserver数据库转存到oracle
- 朴素贝叶斯分类
- Cannot delete or update a parent row: a foreign key constraint fails解决方法
- form的target属性
- ubuntu gedit出错:Failed to connect to the session manager
- 【C++】在头文件中定义全局变量的技巧
- 80端口的烦恼:[3]清除NT Kernel占用80端口
- STM32启动过程分析
- 函数可变参数的处理
- iOS异常处理
- [程序员面试题精选100题]50.树的子结构