ITPub博客

首页 > Linux操作系统 > Linux操作系统 > what is SMON_SCN_TIME ?

what is SMON_SCN_TIME ?

原创 Linux操作系统 作者:sunnily 时间:2019-04-28 16:00:07 0 删除 编辑

SMON_SCN_TIME是Oracle数据库的系统表,用以进行辅助恢复等功能。
在Oracle9iR2中,SMON_SCN_TIME每5分钟被更新一次。

[oracle@jumper oracle]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Dec 19 18:19:27 2005
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
SQL> select * from smon_scn_time where rownum <10;
    THREAD    TIME_MP TIME_DP                SCN_WRP    SCN_BAS
---------- ---------- ------------------- ---------- ----------
1 1134916635 2005-12-18 22:37:15 25 65931
1 1134916648 2005-12-18 22:37:28 25 65979
1 1134917029 2005-12-18 22:43:49 25 66224
1 1134917336 2005-12-18 22:48:57 25 66325
1 1134917643 2005-12-18 22:54:04 25 66426
1 1134917950 2005-12-18 22:59:11 25 66527
1 1134918257 2005-12-18 23:04:18 25 66628
1 1134918564 2005-12-18 23:09:25 25 66733
1 1134918871 2005-12-18 23:14:33 25 66836
9 rows selected.

SMON_SCN_TIME记录5天的数据,也就是1440 ((5d x 24h x 12m = 1440) 条记录。
所以在Oracle9iR2中,表属性修改时间和flashback时间差至少应为5分钟。否则就会出现ORA-01466错误。

[oracle@jumper oracle]$ sqlplus eygle/eygle
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Dec 19 19:34:53 2005
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
19:34:58 SQL> col myscn for 9999999999999999
19:34:58 SQL> variable myscn number;
19:34:58 SQL> create table eygle (c1 number);
Table created.
19:35:00 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:35:00 SQL> print myscn;
            MYSCN
-----------------
107374274756
19:35:00 SQL> insert into eygle values(1);
1 row created.
19:35:00 SQL> commit;
Commit complete.
19:35:00 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:35:00 SQL> print myscn;
            MYSCN
-----------------
107374274777
19:35:00 SQL> select * from eygle as of scn(:myscn);
select * from eygle as of scn(:myscn)
*
ERROR at line 1:
ORA-01466: unable to read data - table definition has changed
19:41:10 SQL> select * from eygle as of scn(:myscn);
select * from eygle as of scn(:myscn)
*
ERROR at line 1:
ORA-01466: unable to read data - table definition has changed
19:43:03 SQL> select dbms_flashback.get_system_change_number myscn from dual;
            MYSCN
-----------------
107374274944
19:43:15 SQL> select * from eygle as of scn 107374274944;
        C1
----------
1

此时SMON_SCN_TIME中的信息如下:

19:45:11 SQL> select * from (select * from smon_scn_time order by time_dp desc) where rownum <5;
    THREAD    TIME_MP TIME_DP                SCN_WRP    SCN_BAS
---------- ---------- ------------------- ---------- ----------
1 1134992658 2005-12-19 19:44:18 25 92565
1 1134992351 2005-12-19 19:39:11 25 92463
1 1134992042 2005-12-19 19:34:04 25 92256
1 1134991731 2005-12-19 19:28:53 25 92149

在Oracle10g中,SMON_SCN_TIME表每6秒被更新一次。所以这个Flashback时间被缩小为6秒。

[oracle@danaly ~]$ sqlplus eygle/eygle
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 19 19:37:19 2005
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
19:37:22 SQL> col myscn for 9999999999999999
19:37:22 SQL> variable myscn number;
19:37:22 SQL> create table eygle (c1 number);
Table created.
19:37:22 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:37:22 SQL> print myscn;
            MYSCN
-----------------
16011230122
19:37:22 SQL> insert into eygle values(1);
1 row created.
19:37:22 SQL> commit;
Commit complete.
19:37:22 SQL> exec :myscn := dbms_flashback.get_system_change_number();
PL/SQL procedure successfully completed.
19:37:22 SQL> print myscn;
            MYSCN
-----------------
16011230124
19:37:22 SQL> select * from eygle as of scn(:myscn);
select * from eygle as of scn(:myscn)
*
ERROR at line 1:
ORA-01466: unable to read data - table definition has changed

19:37:22 SQL> select scn_to_timestamp(16011230124) from dual;
SCN_TO_TIMESTAMP(16011230124)
---------------------------------------------------------------------------
19-DEC-05 07.37.21.000000000 PM
 
19:38:50 SQL> select timestamp_to_scn('19-DEC-05 07.37.27.000000000 PM') MYSCN from dual;
            MYSCN
-----------------
16011230125
19:39:02 SQL> select * from eygle as of scn 16011230125;
        C1
----------
1
-----

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/77580/viewspace-212710/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2004-04-19

  • 博文量
    139
  • 访问量
    125829