eygle.com   eygle.com
eygle.com  
 

« A Gift:Oracle DW/BI 2006 Calendar | Blog首页 | My answer for-9个动态性能视图 »

what is SMON_SCN_TIME ?

作者:eygle |【转载时请务必以超链接形式标明文章和作者信息及本声明
链接:

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

-----
这篇 【what is SMON_SCN_TIME ?】来自 www.eygle.com | CSDN技术网摘| del.icio.us|365Key

By eygle on 2005-12-27 20:19 | Comments (2) | Posted to Internal | Edit |Pageviews:

相关文章 随机文章
  • DBA警世录:DBA千万不要想当然
  • Oracle HowTo:如何更改数据库的SCN?
  • Oracle HowTo: How to deal with Ora-600 4193 error
  • How to repair corruption block use BBED?
  • 重建控制文件恢复丢失表空间一例
  • 《循序渐进Oracle》一书第一章目录
    如何使用DBMS_LOB从文件中加载CLOB数据
    阵列增加硬盘导致IO错误一例
    推荐微软的Windows Defender
    如何使用ftp从Metalink上下载补丁
    网上相关主题:
    Google

    留言 (2)

    所以在Oracle9iR2中,表属性修改时间和flashback时间差至少应为5分钟。否则就会出现ORA-01466错误
    ---------------------------------------------
    Hi, eygle,你说的表属性修改时间是指什么时间呢?LAST_DDL_TIME吗?下面是我在9205下的试验,修改了表的属性后立刻flashback query,但没有报错:
    SQL> alter table TEST20 add name varchar2(20);

    Table altered.

    SQL> exec :myscn := dbms_flashback.get_system_change_number();

    PL/SQL procedure successfully completed.

    SQL> print myscn;

    MYSCN
    -----------------
    8174383932257

    SQL> select * from test20 as of scn(:myscn);

    ID NAME
    ---------- --------------------
    1

    SQL> insert into test20 values(1,'abcd');

    1 row created.

    SQL> commit;

    Commit complete.

    SQL> select * from test20 as of scn(:myscn);

    ID NAME
    ---------- --------------------
    1

    Posted by: waityou81 at September 10, 2007 5:04 PM

    不知道eygle大师是基于什么版本的测试,我在10.1.0.2下测试和楼上的那位兄弟一样。。咋好像没有时间限制,都可以恢复。

    Posted by: Hopewell_Go at September 25, 2007 3:11 PM

    发表留言:



    Remember Me?
    (输入验证码后方可评论,谢谢支持)



    CopyRight © 2004 eygle.com, All rights reserved.