级联删除和更新的优点和缺点是什么? [英] What are the Pros and Cons of Cascading delete and updates?

查看:368
本文介绍了级联删除和更新的优点和缺点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是一个幼稚的问题...但是我认为我们应该始终进行级联的删除和更新。但是我想知道它是否存在问题,我们什么时候不应该这样做?我现在真的想不起来您不想进行级联删除的情况,但是我敢肯定有一种...但是对于更新,应该始终进行吗?

Maybe this is sort of a naive question...but I think that we should always have cascading deletes and updates. But I wanted to know are there problems with it and when should we should not do it? I really can't think of a case right now where you would not want to do an cascade delete but I am sure there is one...but what about updates should they be done always?

那么任何人都可以列出级联删除和更新的优缺点吗?谢谢。

So can anyone please list out the pros and cons of cascading deletes and updates ? Thanks.

推荐答案

优点:


  • 从父表中删除行时,所有外键行都将被删除

  • 这通常比使用触发器来实现这一点要快

  • 孤立行不太可能

缺点


  • 孤儿是可能

  • 如果错误地删除了父表中的一行,则对应的子表中的所有行都将被删除,将由PITA确定您删除的内容

这篇关于级联删除和更新的优点和缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆