Wednesday, March 30, 2022

ORA-01113: file xxx needs media recovery when issuing the 'alter pluggable database enable recovery' command

In DataGuard environment, when one of PDBs are created with STANDBYS=NONE parameter (other situations also are possible), the PDB's datafiles are not physically created on the standby site. Switchover or failover can potentially lead to non-functioning application working with PDB. To overcome this, one should duplicate PDB to standby site. It can be easily accomplished by restoring PDB from primary site and continuing the recovery. But the other days I encountered the issue trying to enable back the recovery of PDB :

> alter pluggable database enable recovery ;
alter pluggable database enable recovery
*
ERROR at line 1:
ORA-01113: file 65 needs media recovery
ORA-01110: data file 65: '...'

It turned out that the CDB was opened in READ ONLY mode before. So, the database behaved as expected - tried to open PDB before enabling recovery (sounds unusual). The solution was simple - restart physical standby in mount mode and repeat the enable recovery.  

Good Luck !