Friday 14 September 2012

How to bring a datafile ONLINE as it is in RECOVER mode because it was OFFLINE(ORA-01113: )

I want  to bring the datafile online but got below error :


SQL> alter database datafile '/home/oracle/oradaata/tbs01.dbf' online;
alter database datafile '/home/oracle/oradaata/tbs01.dbf' online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/home/oracle/oradaata/tbs01.dbf'


I have checked the (status.dba_data_files) then found it's in recover mode
instead it should be in offline mode as DBA have switched it to offline mode earlier

This is due to DBA have not performed the manual checkpoint before switched it to offline .

Solution:

Not need to restore the datafile as it in place.If you have lost your datafile or corupted then only you need to be restore the datafile

Here only needs those ArchiveLogs thatcaptured the Checkpoint of the Datafile and it's being taken OFFLINE

step 1 :

SQL> recover datafile 5;

ORA-00279: change 718137 generated at 12/05/2012 15:32:56 needed for thread 1
ORA-00289: suggestion : archs/1_09.dbf
ORA-00280: change 718137 for thread 1 is in sequence #11714

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/archs/1_11714_785958283.dbf
ORA-00279: change 718252 generated at 12/05/2012 15:33:01 needed for thread 1
ORA-00289: suggestion : archs/1_10.dbf
ORA-00280: change 718252 for thread 1 is in sequence #11715

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/archs/1_11715_785958283.dbf
Log applied.
Media recovery complete.
SQL>

SQL> alter database datafile '/home/oracle/oradaata/tbs01.dbf' online;

Database alterd.

3 comments:

Unknown said...

Vanita,

You´ve help me a LOT!

Tkx!
Vagner Dias

Unknown said...

Welcome Vegner :)

Anonymous said...

Hi Vanita,

I turned my datafile offline because naming was wrong I forgot to add .dbf extension. I have made an ALTER DATABASE DATAFILE '/u02/oradata/PROD/devl16' OFFLINE.
Then I forgot all about it. Now it almost a year now while I was checking datafiles I noticed it seems needs recovery on Enterprise Manager. Oracle Support told me: "Need recovery from archive log sequence of that time onwards until current sequence. To bring offline datafile online,we must recover it to match the SCNs of other datafile headers and hence applying only one archive is not a solution." But unfortunately I do not have all of them I only kept the few ones right after the offline command.
Is this because that is not my only datafile for this tablespace? Could not your solution work for my case also?

Thanks in advance