Hi,
I will continue to explain datafile restore with Flashback Database Technology in Oracle in this article.
Read previous article before this.
https://ittutorial.org/restore-datafile-with-flashback-database-technology-1/
In the previous article we have restored tablespace and datafile with Flashback. But we have taken errors when query the data, and now let’s go to fix these errors.
7-) Not lets go to change datafile mode as offline and then online.
SQL> select * from v$recover_file; FILE# ONLINE ONLINE_ ---------- ------- ------- ERROR CHANGE# ----------------------------------------------------------------- ---------- TIME --------- 7 OFFLINE OFFLINE FILE NOT FOUND 0 8 OFFLINE OFFLINE UNKNOWN ERROR 1857557 25-FEB-15 FILE# ONLINE ONLINE_ ---------- ------- ------- ERROR CHANGE# ----------------------------------------------------------------- ---------- TIME --------- 9 OFFLINE OFFLINE UNKNOWN ERROR 1859232 25-FEB-15
Change tablespace mode as offline.
SQL> alter tablespace ts offline immediate; Tablespace altered.
Change tablespace mode as online.
SQL> alter tablespace ts online; alter tablespace ts online * ERROR at line 1: ORA-01190: control file or data file 9 is from before the last RESETLOGS ORA-01110: data file 9: '/u01/app/oracle/oradata/deneme/ts_01.dbf'
8- But since there is inconsistency in our datafile, we cannot get it online mode. For this we will get help from rman recovery advisor.
We will recover and open database on RMAN Data Recovery Advisor. With this tool, Firstly perform list failure, then Advise failure step and then perform Repair failure like following.
[oracle@MehmetSalih ~]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Wed Feb 25 11:42:59 2015 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: DENEME (DBID=1985990806) RMAN> list failure; List of Database Failures ========================= Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 348 HIGH OPEN 25-FEB-15 One or more non-system datafiles need media recovery 452 HIGH OPEN 25-FEB-15 One or more non-system datafiles are offline 427 HIGH OPEN 25-FEB-15 One or more non-system datafiles are missing RMAN> advise failure; List of Database Failures ========================= Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 348 HIGH OPEN 25-FEB-15 One or more non-system datafiles need media recovery 452 HIGH OPEN 25-FEB-15 One or more non-system datafiles are offline 427 HIGH OPEN 25-FEB-15 One or more non-system datafiles are missing analyzing automatic repair options; this may take some time allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=36 device type=DISK analyzing automatic repair options complete Not all specified failures can currently be repaired. The following failures must be repaired before advise for others can be given. Failure ID Priority Status Time Detected Summary ---------- -------- --------- ------------- ------- 348 HIGH OPEN 25-FEB-15 One or more non-system datafiles need media recovery 427 HIGH OPEN 25-FEB-15 One or more non-system datafiles are missing Mandatory Manual Actions ======================== no manual actions available Optional Manual Actions =======================
-
If you restored the wrong version of data file /u01/app/oracle/oradata/deneme/tb_01.dbf, then replace it with the correct one
-
If you restored the wrong version of data file /u01/app/oracle/oradata/deneme/ts_01.dbf, then replace it with the correct one
-
If file /u01/app/oracle/product/11.2.0.4/db/dbs/UNNAMED00007 was unintentionally renamed or moved, restore it
Automated Repair Options ======================== Option Repair Description ------ ------------------ 1 Restore and recover datafile 7; Recover datafile 8; Recover datafile 9 Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/deneme/deneme/hm/reco_3656126672.hm RMAN> repair failure; Strategy: The repair includes complete media recovery with no data loss Repair script: /u01/app/oracle/diag/rdbms/deneme/deneme/hm/reco_3656126672.hm contents of repair script: # restore and recover datafile restore datafile 7; recover datafile 7; # recover datafile recover datafile 8, 9; Do you really want to execute the above repair (enter YES or NO)? YES executing repair script Starting restore at 25-FEB-15 using channel ORA_DISK_1 creating datafile file number=7 name=/u01/app/oracle/product/11.2.0.4/db/dbs/UNNAMED00007 restore not done; all files read only, offline, or already restored Finished restore at 25-FEB-15 Starting recover at 25-FEB-15 using channel ORA_DISK_1 starting media recovery archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_2_bgv509dy_.arc archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_1_bgv5d0sy_.arc archived log file name=/u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_2_bgv509dy_.arc thread=1 sequence=2 archived log file name=/u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_1_bgv5d0sy_.arc thread=1 sequence=1 archived log file name=/u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_1_bgv5vhq4_.arc thread=1 sequence=1 media recovery complete, elapsed time: 00:00:00 Finished recover at 25-FEB-15 Starting recover at 25-FEB-15 using channel ORA_DISK_1 starting media recovery archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_1_bgv5d0sy_.arc archived log file name=/u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_1_bgv5d0sy_.arc thread=1 sequence=1 archived log file name=/u01/app/oracle/fast_recovery_area/DENEME/archivelog/2015_02_25/o1_mf_1_1_bgv5vhq4_.arc thread=1 sequence=1 media recovery complete, elapsed time: 00:00:01 Finished recover at 25-FEB-15 repair failure complete RMAN> exit
9-) Now problem has been solved, we can query related table and data like following. We have been recovered lost or dropped datafile via Flashback database and RMAN tool.
[oracle@MehmetSalih ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 25 11:44:13 2015 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> alter tablespace ts online; Tablespace altered. SQL> select * from ts.ts; ID ---------- 10
Do you want to learn Oracle Database for Beginners, then read the following articles.
https://ittutorial.org/oracle-database-19c-tutorials-for-beginners/