之前有一些简单介绍SCN的文章:
浅谈SCN_1–从oracle7至今,如何获取scn
浅谈SCN_2–_kcmgas_函数
使用ORACDEBUG 修改 数据库SCN
这个测试是接着上次的使用oradebug修改SCN的,这里使用修改控制文件SCN和相关标示位的方法:
SQL> startup mount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2255832 bytes Variable Size 184550440 bytes Database Buffers 432013312 bytes Redo Buffers 7507968 bytes Database mounted. SQL> select checkpoint_change#,to_char(checkpoint_change#,'XXXXXXXXXXXXXXXXX') from v$database; CHECKPOINT_CHANGE# TO_CHAR(CHECKPOINT ------------------ ------------------ 2726293 299995
这个测试,我们把SCN增加100万,即从 2726293 修改为 3726293。
SQL> select '3726293',to_char(3726293,'XXXXXXXXXXXXXXXXX') from v$database; '372629 TO_CHAR(3726293,'X ------- ------------------ 3726293 38DBD5 SQL>
查看当前控制文件的位置:
SQL> show parameter control NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 control_files string +DATA/lunars/control01.ctl, +D ATA/lunars/control02.ctl control_management_pack_access string DIAGNOSTIC+TUNING SQL>
将控制文件拿到本地,进行修改,修改过程如下:
首先找到数据库SCN:
修改SCN和相关标示位:
讲数据库shutdown,然后将修改后的控制文件copy到ASM中,并使用这个控制文件启动数据库:
ASMCMD> ls CONTROLFILE/ DATAFILE/ ONLINELOG/ TEMPFILE/ control01.ctl control02.ctl lunar01.dbf redo01.log redo02.log redo03.log soe01.dbf sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf ASMCMD> rm control01.ctl ASMCMD> rm control02.ctl ASMCMD> cp /tmp/control01.dbf +DATA/lunars/control01.ctl copying /tmp/control01.dbf -> +DATA/lunars/control01.ctl ASMCMD> cp /tmp/control01.dbf +DATA/lunars/control02.ctl copying /tmp/control01.dbf -> +DATA/lunars/control02.ctl ASMCMD>
Mount数据库,并查看数据库SCN:
SQL> startup mount ORACLE instance started. Total System Global Area 626327552 bytes Fixed Size 2255832 bytes Variable Size 184550440 bytes Database Buffers 432013312 bytes Redo Buffers 7507968 bytes Database mounted. SQL> select checkpoint_change#,to_char(checkpoint_change#,'XXXXXXXXXXXXXXXXX') from v$database; CHECKPOINT_CHANGE# TO_CHAR(CHECKPOINT ------------------ ------------------ 3726293 38DBD5 SQL> alter database open; Database altered. SQL> select checkpoint_change#,to_char(checkpoint_change#,'XXXXXXXXXXXXXXXXX') from v$database; CHECKPOINT_CHANGE# TO_CHAR(CHECKPOINT ------------------ ------------------ 3726296 38DBD8 SQL> SQL>
这里我们看到,数据库的SCN已经修改为我们指定的 3726296了。