Locks are generated when multiple concurrent exclusive accesses, so the isolation in the lock and transaction characteristics is closely related. The isolation level is roughly divided into four kinds.
Read not submitted
Read Committed
REPEATABLE READ
Serializable
Exclusive locks are persisted to the end of the transaction in order to ensure the integrity and consistency of the transaction.
So let's talk about how shared locks are locked under these four isolation levels.
READ UNCOMMITTED: As the name implies, others did not submit I can read, which I read without sharing the lock Bai, read dirty (dirty data and dirty data page is completely different two concepts, swelling data is neither committed nor rollback data, intermediate state, bulging data page is in memory has not redo to disk data, When checkpoint is triggered, it is written to disk in bulk and then marked as clean on the page header.
Read Committed: As the name implies, others submitted I can read, then I read the time is to add a shared lock, but the shared lock is to read a release, the lock will not last until the end of time.
REPEATABLE READ: As the name implies, can be repeated reading, since in a transaction I can read repeatedly, in fact, the consciousness is in a food multiple read data is the same, then this shared lock is continued until the end of the transaction. From Start--commit This period of time shared locks have been held, so other people can not change, will be read more than once.
Serializable: Like a table primary key ID 3 data I want to insert a 2.5 between 2-3 if someone now queries select COUNT (1) from Tbname where Id>=1 and id<=3 is not allowed because this isolation level On the range lock this time not only the data can not be modified, this section of the scope can not insert new data. So the number of times in a transaction count is 3 data, if the table does not have a primary key, there is no aggregation built on the scope of the heap table is not a logical concept, storage is the physical location fileid:pageid:slotnumber, if the heap table this isolation level when reading will be added to the table lock.
This article is from the "Xinle" blog, please be sure to keep this source http://xinle.blog.51cto.com/1935834/1736981
Understanding Lock and Lockout duration