sql server中事务回滚的机制是什么? [英] What is the mechanism for Transaction Rollback in sql server?

查看:69
本文介绍了sql server中事务回滚的机制是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sql server中事务回滚的机制是什么?

What is the mechanism for Transaction Rollback in sql server?

推荐答案

数据库中的每次更新都会首先将一个条目写入包含更改描述的日志中.例如.如果您将列值从 A 更新到 B,日志将包含更新记录,例如:在表 T 中,列 C 已从 A 更改为 B 以通过 ID I 的事务将键 K 的记录更改为 K.如果您回滚事务,引擎将开始向后扫描日志以查找事务完成的工作记录并撤消工作:当它找到从 A 到 B 的更新记录时,会将值更改回 A.插入将被撤消通过删除插入的行.将通过插入回行来撤消删除.这在事务逻辑架构预写事务日志.

Every update in the database will first write an entry into the log containing the description of the change. Eg. if you update a column value from A to B the log will contain a record of the update, something like: in table T the column C was changed from A to B for record with key K by transaction with id I. If you rollback the transaction, the engine will start scanning the log backward looking for records of work done by your transaction and will undo the work: when it finds the record of update from A to B, will change the value back to A. An insert will be undone by deleting the inserted row. A delete will be undone by inserting back the row. This is described in Transaction Log Logical Architecture and Write-Ahead Transaction Log.

这是高级解释,对于外行人来说,这是如何发生的确切内部细节,并且不受您的检查或更改的影响.

This is the high level explanation, the exact internal details how this happen are undocumented for laymen and not subject to your inspection nor changes.

这篇关于sql server中事务回滚的机制是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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