The lock is the means to prevent other transactions from accessing the specified resource. The lock is the main method of implementing concurrent control. Multiple users can simultaneously manipulate data in the same database without data inconsistency. In general, the lock can prevent dirty reading, not repeatable reading and illusion reading. Dirty reading is to refer to a transaction is accessing data and modify the data, and this modification has not been submitted to the database, at this time, another transaction also accesss this data and then uses this data. Because this data is not submitted data, then another transaction reads this data is dirty data, and the operation made by dirty data may be incorrect. It is not repeatable to read the same data multiple times in one transaction. Another transaction also accesses the same data at this business yet. Then, between the two read data in the first transaction, the data read in the first transaction twice can be different due to the modification of the second transaction. This happens that the data read twice in a transaction is different, so it is called whether it is not repeatable. Illustrative reading is a phenomenon that occurs when the transaction is not independent execution, such as the first transaction modifies the data in a table, which involves all the data lines in the table. At the same time, the second transaction also modifies the data in this table, which is inserted into the table new data. Then, in the future, the user finds the first transaction, there is still a modified data, just like an illusion.
I read the article of the netizen a few more time, now add the following isolated concept, thank you Jeex's help here.
The four isolation stages defined in ANSI SQL are actually defined using the lock operation: dirty reading: Do not lock when reading data. Submit Read: Add a read lock before reading the data, and release the lock after reading. Repeatable read: Add a read lock before reading the data, do not release the lock after reading until the lock is released until the transaction rollback or commiT is released. Serialization Read: Packed (called conditional lock) on the read data before reading data, does not release the lock after reading until the lock is released until the transaction rollback or commiT is released.
Update Lost: When the system allows both transactions to update the same data, update is lost.
Dirty Read: Dirty reading when a transaction reads another transaction has not been submitted.
Non-repetition read: The same query is performed many times in the same transaction. Due to the modification or deletion of other submission, return different result sets each time, at this time, non-recurrent reading occurs.
Phantom Read: The same query is performed many times in the same transaction. Due to other transactions, different result sets are returned each time, at this time, fiction occurs.
Below is a phenomenon that the isolation level and its corresponding may or impossible:
Dirty Read NonRepeatable Read Phantom Read Read uncommitted Possible Possible Possible Read committed Not possible Possible Possible Repeatable read Not possible Not possible Possible Serializable Not possible Not possible Not possible