简体   繁体   中英

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 .

  1. If no BEGIN TRANSACTION statement is executed , it will be the default Auto-Commit transaction mode

  2. If you use BEGIN TRANSACTION statement it will be an Explicit Transaction .

  3. Lastly to make use of Implicit Transaction you will need to turn them on by using SET IMPLICIT_TRANSACTIONS ON;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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