Database transactions (III)

Source: Internet
Author: User

Transaction isolation level 
Although the database provides users with a DML Lock operation method, it is very troublesome to directly use lock management. Therefore, the database provides users with an automatic lock mechanism. As long as the User specifies the transaction isolation level of the session, the database will analyze the SQL statements in the transaction, and then automatically add the appropriate lock for the data resources of the transaction operation. In addition, the database will maintain these locks. When there are too many locks on a resource, the database will automatically upgrade the lock to improve the system running performance, this process is completely transparent to users.
ANSI/iso SQL 92 defines four levels of transaction isolation levels. In the same data environment, the same input is used to perform the same work, depending on different isolation levels, it can lead to different results. Different transaction isolation levels have different capabilities to solve data concurrency problems.
Table 1 solutions to concurrency problems at the transaction isolation level

Isolation level Dirty read Non-repeated read Phantom read Category 1 lost updates Type 2 lost updates
READ UNCOMMITED Allow Allow Allow Not Allowed Allow
READ COMMITTED Not Allowed Allow Allow Not Allowed Allow
REPEATABLE READ Not Allowed Not Allowed Allow Not Allowed Not Allowed
SERIALIZABLE Not Allowed Not Allowed Not Allowed Not Allowed Not Allowed

The isolation level of transactions is opposite to the database concurrency. Generally, read uncommited isolation-level databases have the highest concurrency and throughput, while SERIALIZABLE isolation-level databases have the lowest concurrency.

SQL 92 defines READ UNCOMMITED to provide non-blocking READ capability. Although Oracle also supports READ UNCOMMITED, it does not support dirty READ, because Oracle uses a multi-version mechanism to completely solve the problem of reading dirty data during non-blocking reading and ensure read consistency, the read committed isolation level of Oracle has already met the repeatable read isolation level of SQL 92.

In SQL 92, REPEATABLE READ is recommended to ensure data READ consistency. However, you can select an appropriate isolation level based on application requirements.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.