更新是否触发INSERT事件,因为所有更新都是SQL Server中的DELETE +(re)INSERT [英] Does an update trigger an INSERT event as all updates are DELETE + (re)INSERT in SQL Server

查看:64
本文介绍了更新是否触发INSERT事件,因为所有更新都是SQL Server中的DELETE +(re)INSERT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我了解,当您在SQL Server中更新一个或多个行时,该记录将被删除并使用新值重新插入。因此,这是否意味着触发了INSERT事件,或者仅在更新行时才触发UPDATE?

As I understand it, when you update one or more rows in SQL Server, the record is deleted and reinserted with the new values. Does this therefore mean that an INSERT event is triggered, or just an UPDATE when rows are updated?

编辑:突出显示所有懒惰读者的主要信息(尽管我建议您已在davek的以下答案中阅读了完整的链接详细信息):

To highlight the main info for any lazy readers (although I recommend that you read the full link details in davek 's answer below):

SQL是否将所有更新作为拆分更新?

Does SQL do all updates as split updates?

简短的答案是:


NO

NO

稍长一些的答案:


对于更改键值的更新,SQL不会将
用作-

For updates that change the key values, SQL will not do those as in-place updates.


推荐答案

我认为(拆分为delete + insert)当更新需要索引被更新时。看到此链接:

I think that (the split into delete + insert) is only true when the update requires the index to be updated. See this link:

http://www.sqlservercentral.com/blogs/sqlinthewild/2011/06/21/are-all-updates-split-into-delete_2D00_insert_3F00_/

,尤其是最后一段:


现在我们进行了拆分更新。日志中有一个delete_rows和
insert_rows操作。这不是作为就地
更新完成的,那么我们在这里可以得出什么结论? SQL是否将所有更新都作为拆分
更新进行?应当清楚的是,对于未更改索引键
的情况,SQL可以将其作为就地更新进行更新。我不会尝试
并声称它总是会的,这很愚蠢,我没有看过很多
场景(页面拆分和转发行
正在其中最明显的一个),但它可以并且将进行就地
更新。对于更改键值的更新,SQL不会将这些
作为就地更新。保罗解释说,在他的一篇反驳文章中,
a回来了–
http://sqlskills.com/BLOGS/PAUL/post/Do-changes-to-index-keys-really-do-in-place-updates .aspx

这篇关于更新是否触发INSERT事件,因为所有更新都是SQL Server中的DELETE +(re)INSERT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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