read commit;
Oracle采用的也是 read committed
默认是:
mysql> SELECT @@GLOBAL.tx_isolation, @@tx_isolation;
+———————–+—————–+
| @@GLOBAL.tx_isolation | @@tx_isolation |
+———————–+—————–+
| REPEATABLE-READ | REPEATABLE-READ |
+———————–+—————–+
1 row in set (0.00 sec)
set session transaction isolation level read committed;
mysql> SELECT @@GLOBAL.tx_isolation, @@tx_isolation;
+———————–+—————-+
| @@GLOBAL.tx_isolation | @@tx_isolation |
+———————–+—————-+
| REPEATABLE-READ | READ-COMMITTED |
+———————–+—————-+
1 row in set (0.00 sec)
SESSION A:
set autocommit=0;
set session transaction isolation level read committed;
SESSION B:
set autocommit=0;
set session transaction isolation level read committed;
SESSION B:
mysql> insert into t1 values(200);
Query OK, 1 row affected (0.00 sec)
mysql> select * from t1;
+——+
| id |
+——+
| 100 |
| 200 |
+——+
2 rows in set (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
SESSION A:
mysql> select * from t1;
+——+
| id |
+——+
| 100 |
| 200 |
+——+
2 rows in set (0.00 sec
只要B提交,A就能看到