您的位置:首页 > 编程语言 > Go语言

[每日一题] 11gOCP 1z0-052 :2013-09-28 ORA-01555: snapshot too old......................C52

2013-09-30 18:25 423 查看
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/12204587





正确答案:A 重现ORA-01555快照过旧的错误。
[oracle@mydb admin]$ oerr ORA 01555 01555, 00000, "snapshot too old: rollback segment number %s with name \"%s\" too small" // *Cause: rollback records needed by a reader for consistent read are //         overwritten by other writers // *Action: If in Automatic Undo Management mode, increase undo_retention //          setting. Otherwise, use larger rollback segments

建undo表空间
gyj@OCM>  create undo tablespace undotbs2 datafile'/u01/app/oracle/oradata/ocm/undotbs2.dbf' size 10M;   Tablespace created.   gyj@OCM> alter system set undo_tablespace=undotbs2;   System altered.   gyj@OCM> alter system set undo_retention=2 scope=both;   System altered.


第1步、session1: 目标是让b表报快照过旧的报错
gyj@OCM> conn gyj/gyj Connected. gyj@OCM> create table a (id int,cc varchar2(10));   Table created.   gyj@OCM>        insert into a values(1,'hello');   1 row created.   gyj@OCM> commit;   Commit complete.   gyj@OCM> create table b(id int,cc varchar2(10));   Table created.   gyj@OCM>        insert into b values(10,'AAAAAA');   1 row created.   gyj@OCM>        commit;   Commit complete.   gyj@OCM> select * from a;          ID CC ---------- ----------         1 hello   gyj@OCM> select * from b;          ID CC ---------- ----------        10 AAAAAA   gyj@OCM> var x refcursor; gyj@OCM> exec open :x for select * fromb;   PL/SQL procedure successfully completed.

第2步、session2:修改b表,字段cc前镜像"OK"保存在UDNO段中
gyj@OCM> update b set cc='BBBBBB' where id= 10;   1 row updated.   gyj@OCM>   commit;   Commit complete.

第3步、session 3:该条语句就是刷新缓存
sys@OCM> alter system flush buffer_cache;   System altered.

第4步、再开3-5个会话:在A表上行大的事务,多运行几次以确保,回滚段被覆盖
gyj@OCM> begin  2     for i in 1..20000 loop  3      update a set cc='HELLOWWWW';  4      commit;  5     end loop;  6    end;  7   /     PL/SQL procedure successfully completed.

第5步、session 1:在B表上执行查询(第一步的查询)
gyj@OCM>  print :x ERROR: ORA-01555: snapshot too old: rollbacksegment number 21 with name "_SYSSMU21$" too small

ORA-01555快照过旧与Oracle的一致性读有关,一致性读的实现与UNDO有关。那什么是一致性读呢?Oracle读一致性是指一个查询所获得的数据来自同一时间点。


一致性读在Oracle中是一个非常重要的概念, 大家一起跟着我先来做下面的一个实验:

gyj@OCM> create table gyj (id int,name varchar2(10)); Table created. gyj@OCM> insert into gyj values(1,'GGGGGG'); 1 row created. gyj@OCM> commit; Commit complete. gyj@OCM> select * from gyj;         ID NAME ---------- ----------          1 GGGGGG gyj@OCM> var x refcursor gyj@OCM> exec open :x for select * from gyj; PL/SQL procedure successfully completed. gyj@OCM> update gyj set name='YYYYYY' where id=1; 1 row updated. gyj@OCM> commit; Commit complete. gyj@OCM> update gyj set name='JJJJJJ' where id=1; 1 row updated. gyj@OCM> commit; Commit complete. gyj@OCM> print :x         ID NAME ---------- ----------          1 GGGGGG   


能真正看懂为什么print所显示的这个结果是GGGGGG,而并不是JJJJJJ,那就说明你对一致性读已了解过了。

答案B不正确,与闪回区无关。答案C不正确,与闪回归档日志无关。答案D不正确,这个查询去UNDO表空间中去读前镜像的值,这个前镜像被覆盖了。

ORA-01555快照过旧解决办法:(1) 加大UNDO表空间的大小。(2) 减少查询条件范围。QQ:252803295
技术交流QQ群:
DSI&Core Search Ⅰ 群:127149411(2000人技术群:未满)
DSI&Core Search Ⅱ 群:177089463(1000人技术群:未满)
DSI&Core Search Ⅲ 群:284596437(500人技术群:未满)
DSI&Core Search Ⅳ 群:192136702(500人技术群:未满)
DSI&Core Search Ⅴ 群:285030382(500人闲聊群:未满)

MAIL:dbathink@hotmail.com
BLOG: http://blog.csdn.net/guoyjoe
WEIBO:http://weibo.com/guoyJoe0218
ITPUB: http://www.itpub.net/space-uid-28460966.html
OCM: http://education.oracle.com/education/otn/YGuo.HTM
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  试题 内存 11gOCP
相关文章推荐