|
| READ UNCOMMITTED | |
| Terminal 1 | Terminal 2 |
|
|
| |
|
|
This would return the uncommited values;
| READ COMMITTED | |
| Terminal 1 | Terminal 2 |
|
|
|
|
|
|
|
|
|
|
| Repeatable Read | |
| Terminal 1 | Terminal 2 |
|
|
|
|
|
|
| Serializable | |
| Terminal 1 | Terminal 2 |
|
|
BEGIN;
INSERT INTO `product` VALUES (4,'D', 5);
COMMIT;
|
|
|
|
| Example I | |
| Terminal 1 | Terminal 2 |
|
|
|
|
⚠️ Note: After this insert, Terminal 1 will be blocked (it’s waiting for Terminal 2’s lock).
|
|
⚠️ Note: This will cause a deadlock between Terminal 1 and Terminal 2,
because both are waiting on each other’s locks under
Serializable isolation level.
|
|
| Example II | |
| Terminal 1 | Terminal 2 |
|
|
|
|
|
|
|
|
| Example III | |
| Terminal 1 | Terminal 2 |
|
|
|
|
|
|
| Isolation Level | dirty read | non repeatable reads | Phantoms |
|---|---|---|---|
| Read uncommited | Y | Y | Y |
| Read Commited | N | Y | Y |
| Repeatable read | N | N | Y* |
| Serializable | N | N | N |
MySQL at REPEATABLE isolation level: