What happens if you don't commit a transaction to a database (say, SQL Server)?

前端 未结 9 2284
礼貌的吻别
礼貌的吻别 2020-11-27 03:08

Suppose I have a query:

begin tran
-- some other sql code

And then I forget to commit or roll back.

If another client tries to exec

9条回答
  •  误落风尘
    2020-11-27 03:22

    As long as you don't COMMIT or ROLLBACK a transaction, it's still "running" and potentially holding locks.

    If your client (application or user) closes the connection to the database before committing, any still running transactions will be rolled back and terminated.

提交回复
热议问题