Reputation: 4652
According to wiki documentation about database isolation levels, 4 different levels match different locks configurations.
But what lock are itself? Does databases provide this read write locking mechanism or read write locks are just abstractions based on the isolation levels and commits?
It would be nice to get small detailed description of how this isolation levels work in db itself. Have a little hesistation about this. Thanks.
Upvotes: 1
Views: 773
Reputation: 1353
Isolation levels are an abstraction of how to provide a transparent way of simultaneous access and change of data in a database. If your database is capable of isolation, different scenarios can't lead to an inconsistent state.
Example: Imagine a database for bank accounts. To keep it simple, just imagine a table with two rows, a account number and the total balance.
Now, if someone transfers some money from account 1 to account 2 [process 1], while at the same time someone else transfers money from account 2 to account 3 [process 2], what could happen? Let's assume [1] is first, reading the totals of account 1 and 2. Then, [2] get's his turn and is executed completely. [1] is now working with outdated values, thus setting the total of account 2 to a wrong value.
With transactions, [2] would have to wait until [1] has finished the complete procedure. Usually this is implemented with locks, so the database locks everything that [1] has used so far.
Upvotes: 1