Setting the MySQL Isolation level

Source: Internet
Author: User

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 you start a transaction

Set Autocommit=off or start transaction

Understanding of Isolation Levels

1.read UNCOMMITTED

You can see uncommitted data (dirty reads), for example: You believe what people say, but maybe he just says it and doesn't actually do it.

2.read committed

Reads the submitted data. However, data results that may be read multiple times are inconsistent (non-repeatable read, Phantom Read). The reading and writing view is: Read the row data, can write.

3.repeatable Read (MySQL default isolation level)

Can be read repeatedly, but with Phantom read. Read-write view: The data rows read are not writable, but new data can be added to the table. In MySQL, new data for other transactions is not visible and does not produce phantom reads. The multi-version concurrency control (MVCC) mechanism is used to solve the phantom reading problem.

4.serializable

Readable, non-writable. Like a lock in Java, writing data must wait for the end of another transaction.

Related Article

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.