题目部分
在Oracle中,SYS.SMON_SCN_TIME基表的作用是什么?
♣
答案部分
SYS.SMON_SCN_TIME基表用于记录过去时间段中SCN与具体的时间戳(timestamp)之间的映射关系,因为是采样记录这种映射关系,所以SMON_SCN_TIME可以较为粗糙地定位某个SCN的时间信息。实际的SMON_SCN_TIME是一张cluster table簇表。SMON_SCN_TIME基表的数据是由SMON后台进程来维护的。
在Oracle 11g中,该表的创建SQL在$ORACLE_HOME/rdbms/admin/dtxnspc.bsq文件中,可以直接查看:
create cluster smon_scn_to_time_aux ( thread number /* thread, compatibility */ ) tablespace SYSAUX / create index smon_scn_to_time_aux_idx on cluster smon_scn_to_time_aux / create table smon_scn_time ( thread number, /* thread, compatibility */ time_mp number, /* time this recent scn represents */ time_dp date, /* time as date, compatibility */ scn_wrp number, /* scn.wrp, compatibility */ scn_bas number, /* scn.bas, compatibility */ num_mappings number, tim_scn_map raw(1200), scn number default 0, /* scn */ orig_thread number default 0 /* for downgrade */ ) cluster smon_scn_to_time_aux (thread) / create unique index smon_scn_time_tim_idx on smon_scn_time(time_mp) tablespace SYSAUX / create unique index smon_scn_time_scn_idx on smon_scn_time(scn) tablespace SYSAUX /
从Oracle 10g开始,SMON会定时清理SMON_SCN_TIME中的记录。SMON后台进程会每5分钟被唤醒一次,检查SMON_SCN_TIME在磁盘上的映射记录总数,若总数超过144000条,则会使用以下语句删除最老的一条记录(TIME_MP列最小):
delete from smon_scn_time where thread = 0 and time_mp = (select min(time_mp) from smon_scn_time where thread = 0);
若仅仅删除一条记录不足以获得足够的空间,则SMON会反复多次执行以上DELETE语句。可以设置12500事件停止SMON进程对SMON_SCN_TIME。
alter system set events '12500 trace name context forever, level 10';
& 说明:
有关SCN的更多内容可以参考我的BLOG:http://blog.itpub.net/26736162/viewspace-2126407/、http://blog.itpub.net/26736162/viewspace-2148359/
本文选自《Oracle程序员面试笔试宝典》,作者:小麦苗
About Me:小麦苗
● 本文作者:小麦苗,只专注于数据库的技术,更注重技术的运用
● 作者博客地址:http://blog.itpub.net/26736162/abstract/1/
● 本系列题目来源于作者的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
● QQ:646634621 QQ群:618766405
● 提供OCP、OCM和高可用部分最实用的技能培训
● 题目解答若有不当之处,还望各位朋友批评指正,共同进步
本文分享自微信公众号 - DB宝(lhrdba),作者:小麦苗best
原文出处及转载信息见文内详细说明,如有侵权,请联系 yunjia_community@tencent.com 删除。
原始发表时间:2020-04-15
本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。
我来说两句