In the serialization isolation level, a transaction sees only changes committed at the time the transaction—not the query—began and changes made by the transaction itself. A serializable transaction operates in an environment that makes it appear as if no other users were modifying data in the database.
--事务只能看见提交点时事务的变化,就像一个单用户环境一样
Serializable isolation is suitable for environments: --适用条件
如果是串行化完成操作那么表b行值就应该是1,但是实验结果显示都是0。因为我们count函数记数都是在T1时间。
--事务只能看见提交点时事务的变化,就像一个单用户环境一样
Serializable isolation is suitable for environments: --适用条件
- With large databases and short transactions that update only a few rows --很短的事务
- Where the chance that two concurrent transactions will modify the same rows is relatively low --一般没有人修改相同的数据
- Where relatively long-running transactions are primarily read only --相对长时间运行的事务为只读
**注意:SERIALIZABLE并不意味所有事物都能表现的好像是以一种串行方式一个接一个执行。
--以下实验以T0为时间顺序递延EODA@PROD1> create table a( x int);
Table created.
EODA@PROD1> create table b( x int);
Table created.
EODA@PROD1> alter session set isolation_level = serializable; --T1会话1
Session altered.
EODA@PROD1> alter session set isolation_level = serializable; --T2会话2
Session altered.
EODA@PROD1> insert into a select count(*) from b; --T3会话1
1 row created.
EODA@PROD1> insert into b select count(*) from a; --T4会话2
1 row created.
EODA@PROD1> commit; --T5会话1
Commit complete.
EODA@PROD1> commit; --T6会话2
Commit complete.
EODA@PROD1> select * from a;
X
----------
0
EODA@PROD1> select * from b;
X
----------
0
如果是串行化完成操作那么表b行值就应该是1,但是实验结果显示都是0。因为我们count函数记数都是在T1时间。