Use this method when:
1. The database is currently closed
2. The database will be opened during recovery
3. The media failure does not affect the SYSTEM tablespace
Step:
1. Mount the database
2. Take datafile offline
3. Open the database
4. Restore datafile
5. Apply archved redo log and online redo log file
6. Bring the datafile online
实验环境:
备份文件中没有'4 recovery 3'这条记录。
- sys@DENVER> select * from user1.t;
- ID NAME
- ---------- ----------
- 0 bbk
- 1 bbk
- 2 bbk
- 3 bbk
- 4 rows selected.
- sys@DENVER> insert into user1.t values(4,'recover 3');
- 1 row created.
- sys@DENVER> commit;
- Commit complete.
- sys@DENVER> !ls -l /u01/admin/denver/archdest
- total 15600
- -rw-r----- 1 Oracle oinstall 15949312 Jan 7 09:03 1_1_771929980.arc
- sys@DENVER> alter system switch logfile;
- System altered.
- sys@DENVER> !ls -l /u01/admin/denver/archdest
- total 15876
- -rw-r----- 1 oracle oinstall 15949312 Jan 7 09:03 1_1_771929980.arc
- -rw-r----- 1 oracle oinstall 270848 Jan 7 09:17 1_2_771929980.arc
- sys@DENVER> shutdown immediate
- Database closed.
- Database dismounted.
- ORACLE instance shut down.
- sys@DENVER> quit
- Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
- With the Partitioning, OLAP, Data Mining and Real Application Testing options
- [oracle@oracle11gR2 ~]$ rm -f /u01/oradata/md/app1_01.dbf
- [oracle@oracle11gR2 ~]$ ls -l /u01/oradata/md/
- total 2255880
- -rw-r----- 1 oracle oinstall 9846784 Jan 7 09:17 control01.ctl
- -rw-r----- 1 oracle oinstall 104865792 Jan 7 09:17 example01.dbf
- -rw-r----- 1 oracle oinstall 536879104 Jan 7 09:17 perfstat_01.dbf
- ..........................
- [oracle@oracle11gR2 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.1.0 Production on Sat Jan 7 09:19:13 2012
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
- idle> conn /as sysdba
- Connected to an idle instance.
- idle> startup
- ORACLE instance started.
- Total System Global Area 422670336 bytes
- Fixed Size 1336960 bytes
- Variable Size 314575232 bytes
- Database Buffers 100663296 bytes
- Redo Buffers 6094848 bytes
- Database mounted.
- ORA-01157: cannot identify/lock data file 9 - see DBWR trace file
- ORA-01110: data file 9: '/u01/oradata/md/app1_01.dbf'
- idle> col error format a20
- idle> select * from v$recover_file;
- FILE# ONLINE ONLINE_ ERROR CHANGE# TIME
- ---------- ------- ------- -------------------- ---------- ---------
- 9 ONLINE ONLINE FILE NOT FOUND 0
- idle> alter database datafile 9 offline;
- Database altered.
- idle> alter database open;
- Database altered.
- idle> select count(*) from hr.employees;
- COUNT(*)
- ----------
- 107
- idle> select * from user1.t;
- select * from user1.t
- *
- ERROR at line 1:
- ORA-00376: file 9 cannot be read at this time
- ORA-01110: data file 9: '/u01/oradata/md/app1_01.dbf'
- idle> !cp /tmp/backup/cold/app1_01.dbf /u01/oradata/md/
- idle> !ls -l /u01/oradata/md
- total 2266148
- -rw-r----- 1 oracle oinstall 10493952 Jan 7 09:21 app1_01.dbf
- -rw-r----- 1 oracle oinstall 9846784 Jan 7 09:21 control01.ctl
- -rw-r----- 1 oracle oinstall 104865792 Jan 7 09:20 example01.dbf
- -rw-r----- 1 oracle oinstall 536879104 Jan 7 09:20 perfstat_01.dbf
- ..................
- idle> recover datafile 9;
- Media recovery complete.
- idle> alter database datafile 9 online;
- Database altered.
- idle> select * from user1.t;
- ID NAME
- ---------- ----------
- 0 bbk
- 1 bbk
- 2 bbk
- 3 bbk
- 4 recover 3
