Incomplete restoration of accidentally deleted Oracle data files

Source: Internet
Author: User
Application Environment: A table is accidentally deleted. At this time, I cannot restore the entire database, which is too troublesome. So now I will copy the data file from the new database to restore it. Therefore, Oracle cannot only restore a part of the data file when restoring the file, because oracle must ensure that the data file

Application Environment: A table is accidentally deleted. At this time, I cannot restore the entire database, which is too troublesome. So now I will copy the data file from the new database to restore it. Therefore, Oracle cannot only restore a part of the data file when restoring the file, because oracle must ensure that the data file

Application Environment: A table is accidentally deleted. At this time, I cannot restore the entire database, which is too troublesome.

So now I will copy the data file from the new database to restore it.


Oracle cannot restore only a part of the data file when restoring the file, because oracle must ensure that the information in the data file header is consistent, so if we want to restore some files, you must use the following method:


You can create another database and copy the data files to be restored to restore the database. (Of course, not only the data file, but also the system tablespace and undo tablespace)

1)It is easy to create another library. You can create a parameter file, add a line *. db_unique_name = 'rt 'to the parameter file, and modify the control file path.

$ORACLE_SID=rtsqlplus / as sysdba>startup nomount pfile='/tmp/pfile.ora'

What about the control file,

2) Of course, we can restore the previously backed up data file to the path of the control file in our configuration parameter file.

Recovery control file:

rman target >  restore controlfile to '/u01/app/oracle/oradata/test/rt_con01.ctl' from '/tmp/FULL_04pe7jue_1_1.bak';


Now you can mount it.

It cannot be opened now. If you open it now, it will overwrite the original logfile, And it is sure that the original library will have problems.

3) What we need to do here is to restore the data file first:

Use a newname in rman. First, determine the original system, undo, and tablespace file number to be restored.

run {allocate channel di type disk;set newname for datafile 1 to '/tmp/disk1/system01.dbf';set newname for datafile 3 to '/tmp/disk1/undotbs01.dbf';set newname for datafile 9 to '/tmp/disk1/test_01.dbf';restore datafile 1,3,9;}

Of course, if you execute the above command, an error will be reported, because we are creating a new control file, so you need to register it:

Rman> catalog start with '/tmp/FULL_04pe7jue_1_1.bak'

4) then change the redo log in the master database:

select * from v$log;    GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME NEXT_CHANGE#---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------------- ------------NEXT_TIME-------------------         1 1 75 52428800 512 2 YES INACTIVE 4215102 2014-07-26:22:18:25 42151952014-07-26:22:19:55         2 1 74 52428800 512 2 YES INACTIVE 4211699 2014-07-26:20:55:55 42151022014-07-26:22:18:25         3 1 76 52428800 512 2 NO CURRENT 4215195 2014-07-26:22:19:55 2.8147E+14

Group 3 is currently in use, so we can delete group1;

SYS @ _ connect_identifier> alter database drop logfile group 1; the database has been changed. SYS @ _ connect_identifier> alter database add logfile group 1 ('/u01/app/oracle/oradata/test/mredo01.log') size 60 m reuse; the database has been changed.

Delete group 2:

SYS @ _ connect_identifier> alter database drop logfile group 2; the database has been changed. SYS @ _ connect_identifier> alter database add logfile group 2 ('/u01/app/oracle/oradata/test/mredo02.log') size 60 m reuse; the database has been changed.

Then the 3 will follow the switch log and make a full checkpoint:

SYS @ _ connect_identifier> select * from v $ log; GROUP # THREAD # SEQUENCE # bytes blocksize members arc status FIRST_CHANGE # BYTES NEXT_CHANGE # ---------- --- BYTES cannot exceed ---------- NEXT_TIME limit 1 0 62914560 512 1 yes unused 0 0 2 1 0 62914560 512 1 yes unused 0 0 3 1 76 52428800 512 2 No current 4215195 2014-07-26: 22: 19: 55 2.8147E + 14 SYS @ _ connect_identifier> alter system switch logfile; the system has changed. SYS @ _ connect_identifier> alter system checkpoint; the system has been changed. SYS @ _ connect_identifier> alter database drop logfile group 3; the database has been changed. SYS @ _ connect_identifier> alter database add logfile group 3 ('/u01/app/oracle/oradata/test/mredo03.log') size 60 m reuse; the database has been changed.

Change the unnecessary data file in the slave Database

Alter database datafile 2 offline drop;

Alter database datafile 4 offline drop;

Alter database datafile 5 offline drop;

Alter database datafile 6 offline drop;

Alter database datafile 8 offline drop;

Alter database datafile 10 offline drop;

6) change the data file path and archive log file path of the slave database:

SYS @ _ connect_identifier> alter database rename file '/u01/app/oracle/oradata/test/system01.dbf' to '/tmp/disk1/system01.dbf' 2; the database has been changed. SYS @ _ connect_identifier> alter database rename file '/u01/app/oracle/oradata/test/undotbs01.dbf' to '/tmp/disk1/undotbs01.dbf'; the database has been changed. SYS @ _ connect_identifier> alter database rename file '/u01/app/oracle/oradata/test/test_01' to '/tmp/disk1/test_01.dbf'; the database has been changed. SYS @ _ connect_identifier> set LOGSOURCE '/tmp/disk1/arch ';

7) Restore log files:

SYS @ _ connect_identifier> recover database using BACKUP controlfile until cancel; ORA-00279: Change 4203853 (generated at 19:57:38) ORA-00289 required for thread 1: recommended: /tmp/disk1/arch/12773_831746264.dbf ORA-00280: Change 4203853 (for thread 1) in sequence #73

Check the data file path. Log File Path:

SYS @ _ connect_identifier> select * from v $ dbfile; FILE # NAME ---------- ------------------------------------ 10/u01/app/oracle/oradata/test/rman01.dbf 9/tmp/disk1/test_01.dbf 8/tmp/perstat. ora 6/home/oracle/trans. dbf 5/u01/app/oracle/oradata/test/example01.d bf 4/u01/app/oracle/oradata/test/users01.dbf 3/tmp/disk1/undotbs01.dbf 2/u01/app /oracle/oradata/test/sysaux01.db f FILE # NAME ------ ---- ---------------------------------------- 1/tmp/disk1/system01.dbf 9 rows have been selected.

8) Open the database and the task ends:

SYS @ _ connect_identifier> alter database open resetlogs; the database has been changed. SYS @ _ connect_identifier> select * from v $ log; GROUP # THREAD # SEQUENCE # bytes blocksize members arc status FIRST_CHANGE # BYTES NEXT_CHANGE # ---------- --- BYTES cannot exceed ---------- NEXT_TIME limit 1 1 52428800 512 2 no current 4203854: 12: 39: 11 2.8147E + 14 2 1 0 52428800 512 2 yes unused 0 0 3 1 0 52428800 512 2 yes unused 0 0 SYS @ _ connect_identifier>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.