Offlining a datafile

When one offline a datafile before you online the datafile one has to recover the datafile

1) Offline a datafile
SQL> alter database datafile 5 offline;

Database altered.

— Shows datafile is in recover state
SQL> select status from v$datafile where file# = 5;

STATUS
——-
RECOVER

— datafile can’t be made online
SQL> alter database datafile 5 online;
alter database datafile 5 online
*
ERROR at line 1:
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: ‘/u01/oradata/TEST/testtbs_01.dbf’

— recover datafile
SQL> recover datafile ‘/u01/oradata/TEST/testtbs_01.dbf’;
Media recovery complete.
SQL> alter database datafile 5 online;

Database altered.