Case 1:
-
I start a connection to the DB
-
I BEGIN a TRANSACTION
-
I close the connection
What happens to the transaction?
Case 2:
-
I start a connection to the DB
-
I BEGIN a TRANSACTION
-
I start a concurrent connection to the same DB
-
With the second connection I modify the contents of a table
-
With the first connection I ROLLBACK the TRANSACTION
What happens to the modifications?
Case 1: roll back
Case 2: at step 4, you can’t modify rows which are touched by the first connection so there’s no effect: the second connection can’t modify, it will wait (due to the locks).