[sql] view plain copy
- CREATE TABLE `t100` (
- `id` bigint(20) NOT NULL default '0',
- `value` varchar(32) default NULL,
- PRIMARY KEY (`id`)
- ) ;
- mysql>select @@global.tx_isolation, @@tx_isolation;
- +-----------------------+-----------------+
- | @@global.tx_isolation | @@tx_isolation |
- +-----------------------+-----------------+
- | REPEATABLE-READ | REPEATABLE-READ |
- +-----------------------+-----------------+
- 试验4-1:
- SESSION A:
- set autocommit=0;
- SESSION B:
- tSessionA Session B
- |
- set autocommit=0; set autocommit=0;
- | START TRANSACTION; START TRANSACTION;
- |
- | SELECT * FROM t100;
- | empty set
- | INSERT INTO t100 VALUES (1, 'a');
- |
- |
- | SELECT * FROM t100;
- | empty set
- | COMMIT;
- |
- | SELECT * FROM t100;
- | empty set
- |
- | INSERT INTO t100 VALUES (1, 'a');
- | ERROR 1062 (23000):
- | Duplicate entry '1' for key 1
- v (shit,刚刚明明告诉我没有这条记录的)
- 如此就出现了幻读,以为表里没有数据,其实数据已经存在了,傻乎乎的提交后,才发现数据冲突了。