MySQL Tutorials - Herong's Tutorial Examples - Version 4.20, by Dr. Herong Yang
"Read Committed" Isolation Level
A tutorial example is provided on the 'Read Uncommitted' isolation level, where 'non-repeatable read' and other concurrent transactions phenomena could occur.
My next test is about "read committed". Again, I used 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> INSERT INTO User VALUES (2, 'bill'); mysql> SELECT 'Session 2'; +-----------+ | Session 2 | +-----------+ mysql> SET TRANSACTION ISOLATION LEVEL READ COMMITTED; mysql> START TRANSACTION; mysql> SELECT * FROM User WHERE ID=2; +----+------+ | 2 | bill | +----+------+ mysql> UPDATE User SET Name='bob' WHERE ID=2; mysql> SELECT * FROM User WHERE ID=2; +----+------+ | 2 | bob | +----+------+ (Non-repeatable read)
The result clearly shows that "non-repeatable read" could indeed happen in a transaction with "read committed" isolation level. In session 2, the second "SELECT * FROM User WHERE ID=2" statement returned different data than the first "SELECT * FROM User WHERE ID=2" statement.
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