How to recover the datafile in Dataguard Env

In this Oracle tutorial, we will provide information on how to recover the datafile in Dataguard environment
Setup :
We have a Oracle Production env TSPRD which is having the Standby Database TSSTD
CaseStudy 1: Suppose one of the file(For example file# 11) on the primary side(TSPRD) got corrupted. The only solution is to restore the file and recover it
Instead of restoring it from datafile from backup ,we can restore it from standby sideSteps to recover the primary database’s datafile using a copy of a standby database’s datafile.This procedure will work for all file systems including raw or ASM.

1) On standby database, copy datafile from ASM to a file system:

RMAN> backup as copy datafile 11 format ‘/tmp/df11.dbf’;

2) transfer the datafile copy from the standby to the primary host using scp.

On primary database

3) Place the datafile to recover offline.
alter database datafile 11 offline;
4) catalog this datafile copy using rman
catalog datafilecopy ‘/tmp/df11.dbf’;
5) Confirm that datafile exists using rman
list copy of datafile 11;
6) Restore the datafile using rman
restore datafile 11;
7) Recover the datafile using rman
recover datafile 11;
8) Place the datafile online:
alter database datafile 11 online;

CaseStudy 2: 
Suppose one of the file(For example file# 11) on the
primary side(TSSTD) got corrupted. The only solution is to restore the
file and recover it
Instead of restoring it from datafile from backup ,we can restore it from Primary side

Steps to recover the standby database’s datafile using a copy of a primary database’s datafile.
.This procedure will work for all file systems including raw or ASM.
1) Backup the primary database’s datafile using rman
backup as copy datafile 11 format ‘/tmp/df11.dbf’;
2) transfer the file to the standby site using an operating system utility such as scp.
3) catalog the datafile copy on the standby site  using rman
catalog datafilecopy ‘/tmp/df11.dbf’;

4) stop redo apply on the physical standby database.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

5) on the standby site restore the datafile copy.
restore datafile 11;
6) restart redo apply on the physical standby database.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

Hop you like this article on how to recover the datafile in Dataguard.Please do provide feedback.