Você está na página 1de 7

The Datafle Checkpoint SCN:

After a checkpoint completes, Oracle stores the SCN individually in the control fle for each datafle.
Note: It shows the datafile checkpoint SCN for a single datafile in the control file:
SQL>SELECT NAME, CHECKPOINT_CHANGE# FROM V$DATAFILE WHERE NAME LIKE '%USER%';
NAME CHECKPOINT_CHANGE#
-------------------------------------------- --------------------
!"#$%&'&(&OMFD)!*+%*"),'-. #/#010
The System Checkpoint SCN:
Oracle stores the system checkpoint SCN in the control fle.
SQL>SELECT CHECKPOINT_CHANGE# FROM V$DATA2ASE;
CHECKPOINT_CHANGE#
------------------------------
#/#010
The Start SCN:
Oracle stores the checkpoint SCN value in the header of each datafle. This is referred to as the start
SCN because it is used at instance startup time to check if recovery is required.
Note: It shows the checkpoint SCN in the datafile header for a single datafile:
SQL> SELECT NAME, CHECKPOINT_CHANGE# FROM V$DATAFILE_HEADER WHERE NAME LIKE '%USERS")%';
NAME CHECKPOINT_CHANGE#
--------------------------------------------- --------------------------
!"#$%&'&(&OMFD)!*+%*"),'-. #/#010
The Stop SCN:
The stop SCN is held in the control fle for each datafle.
Note: t sho!s the stop SCN for a sin"le datafle !hen the database is open for normal use#
SQL> SELECT NAME, LAST_CHANGE# FROM V$DATAFILE WHERE NAME LIKE '%USERS")%';
NAME LAST_CHANGE#
---------------------------------------------- ------------
U"#ORADATAOMFD)USERS"),D2F
Note:
$urin" normal database operation, the stop SCN is N%&& in the control fle 'or (infnity)* for
all datafles that are online in read+!rite mode.
,hile the database is up and open for use, the system checkpoint in the control fle, the
datafle checkpoint SCN in the control fle, and the start SCN in each datafle header all
match.
Note: SCN after clean S-%T$O,N
After a Clean Shutdo!n After a clean database shutdo!n resultin" from a S-%T$O,N
../$AT/ or S-%T$O,N NO0.A& of the database, follo!ed by STA0T%1 .O%NT, the
previous queries on 23$ATA4AS/ and 23$ATA5&/ return the follo!in"#
SQL>SELECT CHECKPOINT_CHANGE# FROM V$DATA2ASE;
CHECKPOINT_CHANGE#
----------------------------
#/3)45
SQL> SELECT NAME, CHECKPOINT_CHANGE#, LAST_CHANGE# FROM V$DATAFILE WHERE NAME
LIKE '%USER%';
NAME CHECKPOINT_CHANGE# LAST_CHANGE#
------------------------------- ------------------ --------------
!"#$%&'&(&OMFD)!*+%*"),'-. #/3)45 #/3)45
SQL> SELECT NAME, CHECKPOINT_CHANGE# FROM V$DATAFILE_HEADER WHERE NAME LIKE
'%USERS%';
NAME CHECKPOINT_CHANGE#
----------------------------------- -----------------------------
!"#$%&'&(&OMFD)!*+%*"),'-. #/3)45
The Stop SCN:
The stop SCN is held in the control fle for each datafle.
Note: t sho!s the stop SCN for a sin"le datafle !hen the database is open for normal use#
Note: SCN after instance crash
n this case, the stop SCN is not set, !hich is indicated by the N%&& value in the
&AST6C-AN7/8 column.
This information enables Oracle, at the time of the ne9t startup, to determine that the
instance crashed because the checkpoint on shutdo!n !as not performed.
f it had been performed, the &AST6C-AN7/8 and C-/C:1ONT6C-AN7/8 values
!ould match for each datafle as they did durin" a clean shutdo!n.
SQL> SELECT CHECKPOINT_CHANGE# FROM V$DATA2ASE;

CHECKPOINT_CHANGE#
--------------------------------
#/3)46
SQL> SELECT NAME, CHECKPOINT_CHANGE#,LAST_CHANGE# FROM V$DATAFILE WHERE NAME LIKE
'%USER%';
NAME CHECKPOINT_CHANGE# LAST_CHANGE#
------------------------------- ------------------ --------------
!"#$%&'&(&OMFD)!*+%*"),'-. #/3)46

Recovery from a Media Failure:
;. %p until this point, the checkpoint start SCN in the datafle header has al!ays
matched the datafle checkpoint SCN number held in the control fle.
<. This is reasonable because durin" a checkpoint, the datafle checkpoint SCN in the control
fle and the start SCN in the datafle header are both updated, alon" !ith the system
checkpoint SCN.
The follo!in" S=& sho!s the start SCN from the datafle header and datafle checkpoint SCN
from the control fle for the same fle#
;. %nlike the 23$ATA5&/ vie!, there is no stop SCN column in the 23$ATA5&/6-/A$/0 vie!
because 23$ATA5&/6-/A$/0 is not used at instance startup time to indicate that an instance
crash occurred.
<. -o!ever, the 23$ATA5&/6-/A$/0 does provide the Oracle $4.S !ith the information it
requires to perform media recovery.
>. At instance startup, the datafle checkpoint SCN in the control fle and the start SCN in the
datafle header are checked for equality. f they don?t match, it is a si"nal that media recovery
is required.
For example media recovery is required if a media failure has occurred and the ori"inal datafle has
been replaced !ith a backup copy. n this case, the start SCN in the backup copy is less than the
checkpoint SCN value in the control fle, and Oracle requests archived redo lo"s@"enerated at the
time of previous lo" s!itches@in order to reapply the chan"es required to brin" the datafle up to the
current point in time.
,e can identify fles that need recovery after !e have replaced a datafle !ith an older version by
startin" the instance in mount mode and runnin" the follo!in" S=&#
SQL> SELECT FILE#, CHANGE# FROM V$RECOVER_FILE;
FILE# CHANGE#
---------- ----------
5 3)35")
n this e9ample, fle A is the datafle in the %S/0S tablespace. 4y ree9ecutin" the previous S=& to
display the datafle checkpoint SCN in the control fle and the start SCN in the datafle header, !e can
see that the start SCN is older due to the restore of the backup datafle that has taken place#
SQL> SELECT 'CONTROLFILE' 7SCN LOCATION7, NAME, CHECKPOINT_CHANGE# FROM V$DATAFILE
WHERE NAME LIKE '%USER%'
UNION
SELECT 'FILE HEADER', NAME, CHECKPOINT_CHANGE# FROM V$DATAFILE_HEADER WHERE NAME LIKE
'%USER%8;
SCN 9$:&(;$< NAME CHECKPOINT_CHANGE#
-------------- ---------------------------------- --------------------
:$<(%$9.;9+ !"#$%&'&(&OMFD)!*+%*"),'-. #/3)44
.;9+ =+&'+% !"#$%&'&(&OMFD)!*+%*"),'-. #/3)44
Recovery from a Media Failure:
SQL> SELECT 'CONTROLFILE' 7SCN LOCATION7, NAME, CHECKPOINT_CHANGE#
FROM V$DATAFILE WHERE NAME LIKE '%USER%'
UNION
SELECT 'FILE HEADER', NAME, CHECKPOINT_CHANGE#
FROM V$DATAFILE_HEADER WHERE NAME LIKE '%USER%';
SCN location NAME CHECKPOINT_CHANGE#
-------------- ------------------------------------------- --------------------
controlfile /u02/oraata/OM!"#/u$er$0#%&f '#'((#
file )eaer /u02/oraata/OM!"#/u$er$0#%&f '#'*0#
f !e !ere to attempt to open the database, !e !ould receive errors like the follo!in"#
ORA-")))3> .;9+ 5 <++'* ?+';& %+:$@+%A
ORA-")))"> '&(&.;9+ 5> '!"#$%&'&(&OMFD)!*+%*"),'-.'
,e can recover the database by issuin" 0/CO2/0 $ATA4AS/ from S=&B1lus !hile the database
is in a mounted state. f the chan"es needed to recover the database to the point in time before
the crash are in an archived redo lo", then !e !ill be prompted to accept the su""ested name#
ORA-""#0/> :=&<B+ 3)35") B+<+%&(+' &( )))"#"") )4>6">#3 <++'+' .$% (=%+&'
ORA-""#4/> *!BB+*(;$< > !"#$%&'&(&OMFD)&%:=T""")S""""""""0#,ARC
ORA-""#4"> :=&<B+ 3)35") .$% (=%+&' ) ;* ;< *+C!+<:+ #0#
SD+:;.A 9$B> EFRET>G*!BB+*(+' H .;9+<&?+ H AUTO H CANCELI
f !e respond to the prompt usin" A%TO, Oracle applies any archived redo lo"s it needs, follo!ed
by any necessary chan"es in the online redo lo"s, to brin" the database ri"ht up to the last
committed transaction before the media failure that caused the requirement for the restore.
!ncomplete Recovery options:
RMAN> %+:$@+% '&(&-&*+ !<(;9 (;?+ '#"")-))-)">)4>6#>""';
RMAN> %+:$@+% '&(&-&*+ !<(;9 :=&<B+ 3)356/;
Recovery from a Media Failure "sin# a $ackup Control File:
f !e had access to a current control fle at the time of the media failure, then none of the start SCN values in the
datafle headers e9ceeded the system checkpoint SCN number in the control fle. The system checkpoint number is
"iven by the follo!in"#
SQL> SELECT CHECKPOINT_CHANGE# FROM V$DATA2ASE;
Reasons for why Oracle needs to maintain the last system checkpoint value in the control fle as
well as checkpoint SCNs in the control fle for each datafle:
;. ,e mi"ht have read+only tablespaces in our database. n this case, the database checkpoint SCN
increases, and the checkpoint SCN for the datafles in the read+only tablespace remains froCen in the
control fle.
<. ,e mi"ht not have a current control fle available at recovery time. n this case, !e need to restore an
earlier control fle before !e can perform a recovery. The system checkpoint in the control fle may
indicate an earlier chan"e than the start SCN in the datafle headers.
The follo!in" S=& report output sho!s a database !ith a read+!rite tablespace '%S/0S* and read+only
tablespace 'T/ST*. The start SCN in the fle header and the checkpoint SCN in the control fle for T/ST are less than
the system checkpoint value. Once a tablespace is read only, checkpoints have no eDect on the fles in it. The other
read+!rite tablespace has checkpoint values that match the system checkpoint#
SCN 9$:&(;$< NAME CHECKPOINT_CHANGE#
-------------------- ---------------------------------- ----------------
controlfile SYSTEM checkpoint 355390
file header /u02/oradata/OD2/users01d!f 355390
file in controlfile /u02/oradata/OD2/users01d!f 355390
.;9+ =+&'+% !"#$%&'&(&OD#(+*("),'-. 366343
.;9+ ;< :$<(%$9.;9+ !"#$%&'&(&OD#(+*("),'-. 366343
The follo!in" S=& sho!s an e9ample !here the system checkpoint SCN and datafle checkpoint SCN indicate an
earlier chan"e than the start SCN in the datafle header#
SQL> SELECT 'CONTROLFILE' 7SCN LOCATION7,'SJSTEM CHECKPOINT' NAME,CHECKPOINT_CHANGE#
FROM V$DATA2ASE
UNION
SELECT 'FILE IN CONTROLFILE', NAME, CHECKPOINT_CHANGE#
FROM V$DATAFILE WHERE NAME LIKE 'USERS")%'
UNION
SELECT 'FILE HEADER', NAME, CHECKPOINT_CHANGE#
FROM V$DATAFILE_HEADER WHERE NAME LIKE '%USER%8;
SCN location NAME CHECKPOINT_CHANGE#
------------------- ------------------------------ ------------------
file header /u02/oradata/OD2/users01.dbf 355253
controlfile S+STEM c)ec,-oint '''./(
file in controlfile /u02/oraata/O"2/u$er$0#%&f '''./(
f !e try to recover a database in the usual !ay in this situation, Oracle detects that the control fle is older than
some of the datafles, as indicated by the checkpoint SCN values in the datafle headers, and reports the follo!in"
messa"e#
SQL> %+:$@+% '&(&-&*+;
ORA-""#43> %+:$@+%A *+**;$< :&<:+9+' '!+ ($ +%%$%*
ORA-")1)"> %+:$@+%A !*;<B (=+ 2ACKUP CONTROLFILE $D(;$< ?!*( -+ '$<+
f !e !ant to proceed !ith recovery in this situation, !e need to indicate to Oracle that a noncurrent control fle
possibly containin" mismatches in the SCN values identifed by the previous error messa"es is about to be
specifed for recovery by usin" the follo!in" command#

Você também pode gostar