Sample Header Ad - 728x90

Does a commit occur all at same time from a transactional point of view?

1 vote
1 answer
138 views
Assume a "Bank_Account" table exists and contains a single column "balance", where everyone has balance=100. If a transaction performs "update Bank_Account set balance = 200 where 1=1; commit;" Is it possible for any 2 transactions performing a select on the Bank_Account table to have one read 200 and another one read 100 for a different bank account? Or once 200 is returned for a given bank account, all others necessarily return 200 too because the commit was atomic? My database intuition would be that once one reads 200, all others must read 200 because a transaction is atomic, but i also read that some selects can execute without locking the table or rows and return a snapshot of data at the start of a transaction, even assuming read committed isolation level. If that is the case, how do databases implement this behavior without locks? What magic does the commit and the selects perform to assure the selects operate on an atomic, all at same time, behavior of a commit? Thanks
Asked by user1508072 (113 rep)
Dec 22, 2023, 06:53 AM
Last activity: Dec 22, 2023, 09:39 AM