隐式和显式事务之间的区别 [英] Difference between Implicit and Explicit Transaction
问题描述
Sql Server 2008中的Implicit和Explicit交易有什么区别?
What is the difference between Implicit and Explicit transaction in Sql Server 2008?
在TransactionScope背景下会发生什么?我使用TransactionScope,但在Sql服务器分析器中我没有看到开始事务...语句。
What happens in TransactionScope background? I'm using TransactionScope but in Sql server profiler I don't see "Begin transaction..." statement.
它是如何工作的?
推荐答案
- 隐式交易: http://msdn.microsoft.com/en-us/library/ms188317.aspx
- SET IMPLICIT_TRANSACTIONS {ON | OFF} http://msdn.microsoft.com/en-us/library/ms187807.aspx
- Implicit Transactions: http://msdn.microsoft.com/en-us/library/ms188317.aspx
- SET IMPLICIT_TRANSACTIONS { ON | OFF} http://msdn.microsoft.com/en-us/library/ms187807.aspx
基本上,在将TransactionScope设置为Implicit的c#中,它调用SQL Server SET命令将连接置于IMPLICIT_TRANSACTIONS模式中。您所做的任何操作(使用第二个链接中列出的命令之一)都会启动一个保持打开的事务,直到发出提交为止。 如果在连接结束时没有发出提交,则执行隐式ROLLBACK。
Basically, in c# when you set the TransactionScope to Implicit, it calls the SQL Server SET command to put the connection in IMPLICIT_TRANSACTIONS mode. Anything that you do (using one of the commands listed in the 2nd link) starts a transaction that is kept open until a commit is issued. If no commit is issued at the end of a connection, an implicit ROLLBACK is performed.
这与OFF设置不同,它也将每个语句放入一个事务中 - 区别在于在OFF模式下(因此事务是显式的),每个事务(单个语句)立即提交。
This differs from the OFF setting, which also puts every statement into a transaction - the difference is that in the OFF mode (therefore transactions are explicit), each transaction (singular statement) is immediately committed.
这篇关于隐式和显式事务之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!