Oracle SCN Verification & Recovery
1. Problem Identification
The following error occurs when attempting to bring a datafile online or open the database:
ORA-01113: file 2 needs media recovery
ORA-01110: data file 2: '+DATA/UGARY/DATAFILE/sysaux.3716.1204521933'
ORA-01110: data file 2: '+DATA/UGARY/DATAFILE/sysaux.3716.1204521933'
2. Diagnostic Analysis (Control File Dump)
To identify the exact SCN status from the control file, generate a trace file:
SQL> ALTER SESSION SET EVENTS 'immediate trace name controlf level 3';
=========================
to find diag dir
====================================
set linesize 300 pagesize 300
col name form a25
col value form a80 wrap
select * from v$diag_info
where 1=1
and NAME='Diag Trace'
order by name
/
=============
find /u01/app/oracle/diag/rdbms/ugary/ugary/trace -type f -exec grep -il "Controlfile Checkpointed" {} \;
/u01/app/oracle/diag/rdbms/ugary/ugary/trace/ugary_ora_14641.trc <<<<<<< file name
cat ugary_ora_14641.trc| grep -i -A7 -A7 "DATA FILE"
====
If the Stop SCN is 0xffff.ffffffff, the database is in a consistent state and ready to be opened.
However, if the Stop SCN is any other value,you must convert it from Hexadecimal to Decimal to determine the specific SCN required for recovery.
DATA FILE RECORDS
***************************************************************************
(size = 520, compat size = 520, section max = 200, section in-use = 3,
last-recid= 34, old-recno = 0, last-recno = 0)
(extent = 1, blkno = 7, numrecs = 200)
DATA FILE #1:
name #4: +DATA/UGARY/DATAFILE/system.3761.1204521925
creation size=384000 block size=8192 status=0xe flg=0x1 head=4 tail=4 dup=1
pdb_id 0, tablespace 0, index=1 krfil=1 prev_file_in_ts=0 prev_file_in_pdb=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:175 scn: 0x0000.0067aa14 01/08/2026 08:46:53
Stop scn: 0xffff.ffffffff 01/08/2026 06:47:19
Creation Checkpointed at scn: 0x0000.00000008 01/25/2022 05:22:48
--
DATA FILE #2:
name #5: +DATA/UGARY/DATAFILE/sysaux.3716.1204521933
creation size=256000 block size=8192 status=0xe flg=0x1 head=5 tail=5 dup=1
pdb_id 0, tablespace 1, index=2 krfil=2 prev_file_in_ts=0 prev_file_in_pdb=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:175 scn: 0x0000.0067aa14 01/08/2026 08:46:53
Stop scn: 0xffff.ffffffff 01/08/2026 06:47:19
Creation Checkpointed at scn: 0x0000.00000a8b 01/25/2022 05:22:51
--
DATA FILE #3:
name #6: +DATA/UGARY/DATAFILE/undotbs1.4734.1204521933
creation size=38400 block size=8192 status=0xe flg=0x1 head=6 tail=6 dup=1
pdb_id 0, tablespace 2, index=3 krfil=3 prev_file_in_ts=0 prev_file_in_pdb=0
unrecoverable scn: 0x0000.00000000 01/01/1988 00:00:00
Checkpoint cnt:175 scn: 0x0000.0067aa14 01/08/2026 08:46:53
Stop scn: 0xffff.ffffffff 01/08/2026 06:47:19
Creation Checkpointed at scn: 0x0000.00000de6 01/25/2022 05:22:52
Trace File Indicators:
- Stop Scn: 0xffff.ffffffff STILL FUZZY - Database crashed or is currently open. Recovery Required.
- Stop Scn: 0x0000.003A58D9 CLEAN - Database shut down normally. Ready to open.
3. SCN Conversion Table
Use these methods to convert Hexadecimal SCNs from trace files into Decimal values for recovery analysis.
| Method | Command | Example Result |
|---|---|---|
| SQL*Plus | SELECT TO_NUMBER('3A58D9', 'XXXXXXXXXXXX') FROM DUAL; |
3823833 |
| Unix/Linux | echo "ibase=16; 3A58D9" | bc |
3823833 |
| Online | BinaryHexConverter.com | 3823833 |
4. RMAN Recovery Procedure
Execute these commands in the RMAN prompt to resolve ORA-01113:
# Connect to RMAN
$ rman target /
# Run Recovery
RMAN> RECOVER DATAFILE 2;
# Bring File Online
RMAN> ALTER DATABASE DATAFILE 2 ONLINE;
$ rman target /
# Run Recovery
RMAN> RECOVER DATAFILE 2;
# Bring File Online
RMAN> ALTER DATABASE DATAFILE 2 ONLINE;
5. Automated Monitoring Query
Run this query to check the consistency of all datafiles at once:
==================================
SET PAGESIZE 100 LINESIZE 300 FEEDBACK OFF
COLUMN name FORMAT a50
COLUMN status FORMAT a20
SELECT CON_ID, file#, name, checkpoint_change#, last_change#,
CASE
WHEN last_change# IS NULL THEN 'STILL FUZZY/OPEN'
ELSE 'CLEAN SHUTDOWN'
END AS status
FROM v$datafile; ----- ==================================
--Identifying the Required Archive Logs If RMAN asks for a specific log, you can use the Decimal SCN you calculated earlier (3823833) to find which log is needed: SQL SELECT THREAD#, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE# FROM V$ARCHIVED_LOG WHERE 3823833 BETWEEN FIRST_CHANGE# AND NEXT_CHANGE#; Complete Database Recovery (Alternative) If multiple files are "Fuzzy" (as seen in your v$datafile query), it is often better to recover the whole database: SQL # From RMAN target / STARTUP MOUNT; RECOVER DATABASE; ALTER DATABASE OPEN; set linesize 200 pagesize 200
column member format a50
column first_change# format 99999999999999999999
column next_change# format 99999999999999999999
select l.thread#,
lf.group#,
lf.member,
trunc(l.bytes/1024/1024) as size_mb,
l.status,
l.archived,
lf.type,
lf.is_recovery_dest_file as rdf,
l.sequence#,
l.first_change#,
l.next_change#
from v$logfile lf , v$log l
where l.group# = lf.group#
order by l.thread#,lf.group#, lf.member;
SET PAGESIZE 100 LINESIZE 300 FEEDBACK OFF
COLUMN name FORMAT a50
COLUMN status FORMAT a20
SELECT CON_ID, file#, name, checkpoint_change#, last_change#,
CASE
WHEN last_change# IS NULL THEN 'STILL FUZZY/OPEN'
ELSE 'CLEAN SHUTDOWN'
END AS status
FROM v$datafile; ----- ==================================
--Identifying the Required Archive Logs If RMAN asks for a specific log, you can use the Decimal SCN you calculated earlier (3823833) to find which log is needed: SQL SELECT THREAD#, SEQUENCE#, FIRST_CHANGE#, NEXT_CHANGE# FROM V$ARCHIVED_LOG WHERE 3823833 BETWEEN FIRST_CHANGE# AND NEXT_CHANGE#; Complete Database Recovery (Alternative) If multiple files are "Fuzzy" (as seen in your v$datafile query), it is often better to recover the whole database: SQL # From RMAN target / STARTUP MOUNT; RECOVER DATABASE; ALTER DATABASE OPEN; set linesize 200 pagesize 200
column member format a50
column first_change# format 99999999999999999999
column next_change# format 99999999999999999999
select l.thread#,
lf.group#,
lf.member,
trunc(l.bytes/1024/1024) as size_mb,
l.status,
l.archived,
lf.type,
lf.is_recovery_dest_file as rdf,
l.sequence#,
l.first_change#,
l.next_change#
from v$logfile lf , v$log l
where l.group# = lf.group#
order by l.thread#,lf.group#, lf.member;
Internal Database Documentation - Generated for UGARY Environment
