Query the mysql transaction isolation level

Source: Internet
Author: User
Query mysql transaction isolation level 1. view the current session isolation level

Select @ tx_isolation;

2. view the current isolation level of the system

Select @ global. tx_isolation;

3. set the current session isolation level

Set session transaction isolatin level repeatable read;

4. set the current isolation level of the system

Set global transaction isolation level repeatable read;

5. command line, when starting the transaction

Set autocommit = off or start transaction

Isolation level

1. read uncommitted

We can see uncommitted data (dirty reads). For example, you believe what others say, but maybe they just talk about it and don't actually do it.

2. read committed

Read the submitted data. However, the data read results may be inconsistent (repeated reading is not allowed, phantom reading ). Read/Write: Read row data can be written.

3. repeatable read (default MySQL isolation level)

It can be read repeatedly, but there is phantom read. Read/write View: read data rows cannot be written, but data can be added to the table. In MySQL, the newly added data of other transactions is invisible and does not generate phantom reads. Multi-version concurrency control (MVCC) mechanism is used to solve Phantom read problems.

4. serializable

Readable and not writable. Like a lock in java, writing data must wait until another transaction ends.

For an understanding of the isolation level, see the andyhu1007 article: http://www.iteye.com/topic/322382

Default isolation level: RR

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.