实验过程如下:
创建表:
1 2 3 4 5 6 |
SQL> desc t1 Name Null? Type ----------------------------------------- -------- ---------------------------- ID NUMBER NAME VARCHAR2(20) TIME TIMESTAMP(6) |
创建存储过程P1
1 2 3 4 5 6 7 8 9 |
create or replace procedure p1 AS begin for i in 1 .. 100 loop update t1 set name='test' , time=systimestamp where id < 10; dbms_lock.sleep(1); end loop; commit; end; |
创建实验数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
SQL> select * from t1; no rows selected SQL> insert into t1 values(1,1,systimestamp); 1 row created. SQL> commit; Commit complete. SQL> select * from t1; ID NAME TIME ---------- -------------------- ---------------------------------------- 1 1 14-JAN-16 12.57.40.240436 PM |
模拟事务操作:
1 |
SQL> exec p1; |
向表中插入新数据:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
SQL> insert into t1 values(2,2,systimestamp); 1 row created. SQL> commit; Commit complete. SQL> select * from t1; ID NAME TIME ---------- -------------------- ---------------------------------------- 2 2 14-JAN-16 12.58.52.797580 PM 1 1 14-JAN-16 12.57.40.240436 PM SQL> insert into t1 values(3,3,systimestamp); 1 row created. SQL> commit; Commit complete. SQL> select * from t1; ID NAME TIME ---------- -------------------- ---------------------------------------- 2 2 14-JAN-16 12.58.52.797580 PM 3 3 14-JAN-16 01.00.02.994254 PM 1 1 14-JAN-16 12.57.40.240436 PM |
事务执行完毕:
1 2 3 |
SQL> exec p1; PL/SQL procedure successfully completed. |
查询表数据:
1 2 3 4 5 6 7 |
SQL> / ID NAME TIME ---------- -------------------- ---------------------------------------- 2 test 14-JAN-16 01.00.13.248013 PM 3 test 14-JAN-16 01.00.13.248013 PM 1 test 14-JAN-16 01.00.13.248013 PM |
结论:
ORACLE 的多版本一致性是基于语句的,不是基于事务的。
正如某书籍中描述的一样:
READ COMMITTED
Enforces serialization at the statement level. This means that every statement will get a consistent view of the data as it existed at the start of that statement. However,since a transaction can contain more than one statement, it’s possible that nonrepeatable reads and phantom reads can occur within the context of the complete transaction. The READ COMMITTED isolation level is the default isolation level for Oracle.
SERIALIZABLE
Enforces serialization at the transaction level. This means that every statement within a transaction will get the same consistent view of the data as it existed at the start of the transaction
请问,你这篇文章#https://blog.csdn.net/yidian815/article/details/16891021#中提到的大师的实验过程或链接可否给我一个,感谢,我的邮箱是15901513615@163.com