【OCP最新题库解析(052)--题7】 Examine theses SQL statements and output
Examine theses SQL statements and their output:
S QL>select name,value
2 from v$parameter
3 where name like ' undo% ' ;
NAME VALUE
- -------------------- ---------------------------------------------
undo_management AUTO
undo_tablespae UNDO
undo_retention 900
S QL>select contents,retention
2 from dba_tablespaces
3 where tablespace_name= ' UNDO ' ;
CONTENTS RETENTION
- ------------- --------------------
U NDO GUARANTEE
S QL>select blocks,autoextensible,maxblocks
2 from dba_data_files
3 Where tablespace_name= ' UNDO ' ;
BLOCKS AUT MAXBLOCKS
- ------------ ------- ------------------
6 400 NO 0
Which two are true?
A) E xpired undo will be retained as long as possible within the limits of the current size of the UNDO tablespace.
B) A ctive UNDO will be retained as long as needed by the transactions.
C) T ransactions will wait until free space becomes avallable in the UNDO tablespace when they have failed to allocate space.
D) I nactive UNDO will be retained for at least 15 minutes.
E) The UNDO tablespace will grow automatically if there is not enough space to retain active UNDO.
A nswer : BD
对于 A 选项, E xpired undo 会被覆盖。
对于 C 选项,空间不足会报错,不会等待。
对于 E 选项, autoextensible 列的值为 NO ,表示非自动扩展。
Undo 信息存储在 Undo 段中, Undo 段又存储在 Undo 表空间中。 Undo 表空间仅用于 Undo 段(在 Undo 表空间中不能创建其它段类型,例如表、索引等),只能与单个实例相关联。在任意指定时间,一个给定的实例只能有一个表空间是当前可写 Undo 表空间。 Undo 表空间是永久的、本地管理的表空间(具有自动区分配),它们由数据库自动进行管理。
Oracle Undo 段中区 3 种状态( DBA_UNDO_EXTENTS 的 STATUS 列): ACTIVE 、 EXPIRED 和 UNEXPIRED :
l ACTIVE 即 未提交的 Undo 信息(活动) : 表示事物还在活动,该值对应的 Undo 段的 DBA_ROLLBACK_SEGS.STATUS 一定是 ONLINE 状态,一旦没有活动的事务在使用 Undo 段,那么对应的 Undo 段就变成 OFFLINE 状态。 ACTIVE 状态的 Undo 区不会被覆盖。
l EXPIRED 即过期的 Undo 信息(过期): 表示事务已经提交且超过了 UNDO_RETENTION 指定时间,该状态可以被覆盖使用。
l UNEXPIRED 即 提交的 Undo 信息(未过期) : 表示事务已经提交但是还没有超过 UNDO_RETENTION 指定时间,该状态可以被覆盖使用。
关于 Undo 表空间有如下几个参数:
SYS@orclasm > show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
_undo_autotune boolean FALSE
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDOTBS1
l UNDO_RETENTION 参数指定已提交的 Undo 信息要保留多长时间(单位为秒),默认为 900 秒(即 15 分钟)。但是该值不是绝对的, 也就是说,如果有其 它 事务需要 Undo 空间,而 Undo 空间出现不足时,这些信息仍然会被覆盖。 只有当表空间设置为 GUARANTEE 时,才能确保已提交的数据保留 UNDO_RETENTION 参数设置的时间。 RETENTION GUARANTEE 是表空间属性而不是初始化参数,此属性只可使用 SQL 命令行语句来更改。通过更改 Undo 表空间来保证保留时间的语法是:
SQL>ALTER TABLESPACE undotbs1 RETENTION GUARANTEE;
要将有保留时间保证的还原表空间返回到其常规设置,请使用以下命令:
SQL>ALTER TABLESPACE undotbs1 RETENTION NOGUARANTEE;
查询保留时间状态:
SQL> SELECT RETENTION FROM DBA_TABLESPACES WHERE TABLESPACE_NAME LIKE 'UNDO%';
如果设置 UNDO_RETENTION 为 ,那么 Oracle 启用自动调整 UNDO_RETENTION ( auto tuning of undo_retention ) 以满足最长运行查询的需要,在告警日志文件中可以看到如下信息:
Autotune of undo retention is turned on.
可以通过设置 “ " _undo_autotune " =FALSE ”来显式 的关闭自动调整 UNDO_RETENTION 功能。
About Me
........................................................................................................................ ● 本文作者:小麦苗,部分内容整理自网络,若有侵权请联系小麦苗删除 ● 本文在itpub( http://blog.itpub.net/26736162 )、博客园( http://www.cnblogs.com/lhrbest )和个人weixin公众号( xiaomaimiaolhr )上有同步更新 ● 本文itpub地址: http://blog.itpub.net/26736162 ● 本文博客园地址: http://www.cnblogs.com/lhrbest ● 本文pdf版、个人简介及小麦苗云盘地址: http://blog.itpub.net/26736162/viewspace-1624453/ ● 数据库笔试面试题库及解答: http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA宝典今日头条号地址: http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ群号: 230161599 (满) 、618766405 ● weixin群:可加我weixin,我拉大家进群,非诚勿扰 ● 联系我请加QQ好友 ( 646634621 ) ,注明添加缘由 ● 于 2018-08-01 06:00 ~ 2018-08-31 24:00 在魔都完成 ● 最新修改时间:2018-08-01 06:00 ~ 2018-08-31 24:00 ● 文章内容来源于小麦苗的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解 ● 版权所有,欢迎分享本文,转载请保留出处 ........................................................................................................................ ● 小麦苗的微店 : https://weidian.com/s/793741433?wfr=c&ifr=shopdetail ● 小麦苗出版的数据库类丛书 : http://blog.itpub.net/26736162/viewspace-2142121/ ● 小麦苗OCP、OCM、高可用网络班 : http://blog.itpub.net/26736162/viewspace-2148098/ ● 小麦苗腾讯课堂主页 : https://lhr.ke.qq.com/ ........................................................................................................................ 使用 weixin客户端 扫描下面的二维码来关注小麦苗的weixin公众号( xiaomaimiaolhr )及QQ群(DBA宝典)、添加小麦苗weixin, 学习最实用的数据库技术。 ........................................................................................................................ |
![]() | ![]() |
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26736162/viewspace-2213221/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26736162/viewspace-2213221/