简体   繁体   English

IMPLICIT TRANSACTIONS ON / OFF和BEGIN / COMMIT交易

[英]IMPLICIT TRANSACTIONS ON/OFF and BEGIN /COMMIT Transaction

我相信默认设置是自动提交DML语句(默认为IMPLICIT TRANSACTIONS ON)但如果我需要执行BEGIN / COMMIT事务,那么在该BEGIN / COMMIT事务中,IMPLICIT TRANSACTION设置是否会自动关闭?

No default behavior is not Implicit Transactions, In Implicit Transactions each statement is wrapped in a new Transaction and then you have to explicitly commit it or rollback it. 没有默认行为不是隐式事务,在隐式事务中,每个语句都包装在一个新的事务中,然后您必须显式提交或回滚它。

Default behavior is Auto-Commit where each statement is wrapped in a transaction and on successful execution it is committed. 默认行为是自动提交,其中每个语句都包含在事务中,并且在成功执行时它将被提交。

Explicit Transactions are when you explicitly Begin a transaction and explicitly commit a transaction, you do not need to turn off or on anything for this, just use BEGIN TRANSACTION before your SQL Statement and you would have started an explicit transaction, now you will have to explicitly COMMIT TRANSACTION or ROLLBACK TRANSACTION . 显式事务是当您显式地开始事务并显式提交事务时,您不需要为此关闭或打开任何内容,只需在SQL语句之前使用BEGIN TRANSACTION并且您将启动显式事务,现在您将不得不显式COMMIT TRANSACTIONROLLBACK TRANSACTION

  1. If no BEGIN TRANSACTION statement is executed , it will be the default Auto-Commit transaction mode 如果未执行BEGIN TRANSACTION语句,则它将是默认的自动提交事务模式

  2. If you use BEGIN TRANSACTION statement it will be an Explicit Transaction . 如果使用BEGIN TRANSACTION语句,则它将是Explicit Transaction

  3. Lastly to make use of Implicit Transaction you will need to turn them on by using SET IMPLICIT_TRANSACTIONS ON; 最后,要使用隐式事务,您需要使用SET IMPLICIT_TRANSACTIONS ON;打开它们SET IMPLICIT_TRANSACTIONS ON;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM