建立测试环境: Enterprise Edition Release

来源:这里教程网 时间:2026-03-03 16:30:19 作者:

Enterprise Edition Release --//changes.这里的avoid rollback,意味着在满足特定的条件时,Oracle就不做一致读了.  --//这个提前条件就是索引要唯一.  --//自己好奇补充一些测试一致性读取的情况。  1.环境:  SCOTT@book> @ ver1  PORT_STRING                    VERSION        BANNER  ------------------------------ -------------- --------------------------------------------------------------------------------  x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production  CREATE OR REPLACE FUNCTION SCOTT.sleep (seconds IN NUMBER)     RETURN NUMBER  AS  BEGIN     sys.DBMS_LOCK.sleep (seconds);     RETURN seconds;  END;  2.建立测试环境:  SCOTT@book> create table t as select rownum id1,rownum id2,lpad(rownum||'x',10,rownum||'x') vc from dual connect by level<=10;  Table created.  SCOTT@book> create unique index i_t_id1 on t(id1);  Index created.  SCOTT@book> create  index i_t_id2 on t(id2);  Index created.  --//分析略.  3.测试:  --//session 1:  SCOTT@book> select * from t where id1=4 and sleep(12)=12 union all select * from t where id2=4 and sleep(1)=12;  --//session 2,以下命令最好事先输入,避免12秒内无法完成:  SCOTT@book> update t set vc=upper(vc) where id1=4;  1 row updated.  SCOTT@book> commit ;  Commit complete.  --//session 1:  SCOTT@book> select * from t where id1=4 and sleep(12)=12 union all select * from t where id2=4 and sleep(12)=12;         ID1        ID2 VC  ---------- ---------- --------------------           4          4 4X4X4X4X4X           4          4 4X4X4X4X4X  --//你可以发现vc输出是大写.而按照我前面的测试应该第1行vc应该是小写,第2行输出的vc是大写。  4.继续测试:  --//条件反过来查询呢?  --//session 1:  SCOTT@book> select * from t where id2=3 and sleep(12)=12 union all select * from t where id1=3 and sleep(12)=12;  --//session 2:  SCOTT@book> update t set vc=upper(vc) where id1=3;  1 row updated.  SCOTT@book> commit ;  Commit complete. 

相关推荐