
在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文件中,可以直接查看:
1create cluster smon_scn_to_time_aux (
2 thread number /* thread, compatibility */
3) tablespace SYSAUX
4/
5create index smon_scn_to_time_aux_idx on cluster smon_scn_to_time_aux
6/
7create table smon_scn_time (
8 thread number, /* thread, compatibility */
9 time_mp number, /* time this recent scn represents */
10 time_dp date, /* time as date, compatibility */
11 scn_wrp number, /* scn.wrp, compatibility */
12 scn_bas number, /* scn.bas, compatibility */
13 num_mappings number,
14 tim_scn_map raw(1200),
15 scn number default 0, /* scn */
16 orig_thread number default 0 /* for downgrade */
17) cluster smon_scn_to_time_aux (thread)
18/
19create unique index smon_scn_time_tim_idx on smon_scn_time(time_mp)
20 tablespace SYSAUX
21/
22create unique index smon_scn_time_scn_idx on smon_scn_time(scn)
23 tablespace SYSAUX
24/
从Oracle 10g开始,SMON会定时清理SMON_SCN_TIME中的记录。SMON后台进程会每5分钟被唤醒一次,检查SMON_SCN_TIME在磁盘上的映射记录总数,若总数超过144000条,则会使用以下语句删除最老的一条记录(TIME_MP列最小):
1delete from smon_scn_time
2 where thread = 0
3 and time_mp = (select min(time_mp) from smon_scn_time where thread = 0);
若仅仅删除一条记录不足以获得足够的空间,则SMON会反复多次执行以上DELETE语句。可以设置12500事件停止SMON进程对SMON_SCN_TIME。
1alter 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程序员面试笔试宝典》,作者:小麦苗

---------------优质麦课------------

详细内容可以添加麦老师微信或QQ私聊。

● 本文作者:小麦苗,只专注于数据库的技术,更注重技术的运用
● 作者博客地址:http://blog.itpub.net/26736162/abstract/1/
● 本系列题目来源于作者的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解
● 版权所有,欢迎分享本文,转载请保留出处
● QQ:646634621 QQ群:618766405
● 提供OCP、OCM和高可用部分最实用的技能培训
● 题目解答若有不当之处,还望各位朋友批评指正,共同进步
长按下图识别二维码或微信扫描下图二维码来关注小麦苗的微信公众号:xiaomaimiaolhr,学习最实用的数据库技术。







