Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the mysql transaction and isolation level?

Shulou Source: shulou.com Published: 2022-06-01 18:57:54 10月05日 Update

Transaction and isolation level

The concept of transaction: transaction is a series of operations on the database as a whole, either all successful or all failed, the use of transactions we can ensure the integrity of the database, transactions are atomic.

Isolation level: the isolation level defines the isolation distance between transactions.

Dirty reads (dirty read): dirty reads occur when one transaction reads uncommitted modifications from another transaction.

Non-repeatable read (nonrepeated read): the same query is performed many times in the same transaction, and the results returned each time are different because the changes made by other transactions are committed, and non-repeatable reading occurs.

Phantom read: the same query is performed multiple times in the same transaction, resulting in different result sets each time due to additions or deletions made by other transactions or commits.

Non-repeatable reading focuses on modification, while phantom reading focuses on adding or deleting. To solve the problem of unrepeatable reading, you only need to lock the rows that meet the conditions, and to solve the phantom reading, you need to lock the table.

There are four transaction isolation levels for MySQL

Read unsubmitted (Read uncommitted)

Read submitted (Read committed)

Repeatable read (Repeated read)

Serializable (Serializable)

The default isolation level of MySQL is: repeatable (Repeated read)

These are the details of the mysql isolation level, please pay attention to other related articles!

Tags: Transactions isolation levels differences data databases results either queries success between content atomic integrity that is whole articles more conditions concepts Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology Xiaomi Linux OPPO Reno