MySQL Tutorials - Herong's Tutorial Examples - Version 4.20, by Dr. Herong Yang
"Read Uncommitted" Isolation Level
A tutorial example is provided on the 'Read Uncommitted' isolation level, where Dirty Read and other concurrent transactions phenomena could occur.
To understand better the "Read Uncommitted" isolation level, I did the following test with two command window sessions.
mysql> SELECT 'Session 1'; +-----------+ | Session 1 | +-----------+ mysql> DROP TABLE IF EXISTS User; mysql> CREATE TABLE User (ID INT PRIMARY KEY, Name CHAR(8)) ENGINE=InnoDB; mysql> START TRANSACTION; mysql> INSERT INTO User VALUES (2, 'bill'); mysql> SELECT 'Session 2'; +-----------+ | Session 2 | +-----------+ mysql> SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; mysql> START TRANSACTION; mysql> SELECT * FROM User; +----+------+ | 2 | bill | +----+------+ mysql> SELECT CURRENT_TIME(); mysql> ROLLBACK; mysql> SELECT * FROM USER; Empty set (0.00 sec)
The result clearly shows that "dirty read" could indeed happen in a transaction with "read uncommitted" isolation level. In the session 2, the second "SELECT * FROM USER;" returned no record. This makes the first "SELECT * FROM USER;" statement becoming a "dirty read".
Last update: 2015.
Table of Contents
MySQL Introduction and Installation
Introduction of MySQL Programs
Perl Programs and MySQL Servers
PHP Programs and MySQL Servers
Java Programs and MySQL Servers
Character Strings and Bit Strings
Table Column Types for Different Types of Values
Using DDL to Create Tables and Indexes
Using DML to Insert, Update and Delete Records
Using SELECT to Query Database
►Transaction Management and Isolation Levels
Transaction Management in MySQL
►"Read Uncommitted" Isolation Level
"Read Committed" Isolation Level
"Repeatable Read" Isolation Level
Defining and Calling Stored Procedures