1. Datafile is lost that was never backed up
2. Cannot be used when it is a file from the SYSTEM tablespace
3. Cannot be used if the control file has been recreated
If a datafile is damaged and no backup of the file is available, then you can still recover the datafile if:
1. All archive log files written after the creation of the original datafile are available
2. The control file contains the name of the damaged file(that is, the control file is current, or is a backup taken after the damaged datafile was added to the database)
Note: You cannot re-created any of the datafile for the SYSTEM tablespace by using the CREATE DATAFILE cluase of the ALTER DATABASE statement because the neccessary redo is not available.
Re-create Lost Datafiles
1. Used when missing datafile cannot be restored because it had never been backed up.
2. Description of missing datafile is still in data dictionary and control file
3. Re-create the datafile : SQL> ALTER DATABASE CREATE DATAFILE 'filename';
4. Re-create the datafile with a different filename;
5. SQL> ALTER DATABASE CREATE DATAFILE 'filename' AS 'new file name';
Step:
1. Take te datafile or tablespace offline
2. Re-create the datafile
3. Apply archived log file and redo log file
4. Bring the datafile or tablespace online
- 实验环境:
- sys@DENVER> CREATE TABLESPACE app2 DATAFILE '/u01/oradata/md/app02_01.dbf' SIZE 10M;
- Tablespace created.
- sys@DENVER> conn user1/user1
- Connected.
- user1@DENVER> CREATE TABLE t2(id int, name varchar2(20)) TABLESPACE app2;
- Table created.
- user1@DENVER> INSERT INTO t2 VALUES(0,'recvery 4');
- 1 row created.
- sys@DENVER> COMMIT;
- Commit complete.
- user1@DENVER> SELECT * FROM t2;
- ID NAME
- ---------- --------------------
- 0 recvery 4
- user1@DENVER> conn /as sysdba
- Connected.
- sys@DENVER> ALTER SYSTEM CHECKPOINT;
- System altered.
- sys@DENVER> !ls -l /u01/oradata/md/
- total 2276416
- -rw-r----- 1 Oracle oinstall 10493952 Jan 7 09:35 app02_01.dbf
- -rw-r----- 1 oracle oinstall 10493952 Jan 7 09:35 app1_01.dbf
- -rw-r----- 1 oracle oinstall 9846784 Jan 7 09:35 control01.ctl
- .............................
- sys@DENVER> !rm -f /u01/oradata/md/app02_01.dbf
- sys@DENVER> !ls -l /u01/oradata/md/
- total 2266148
- -rw-r----- 1 oracle oinstall 10493952 Jan 7 09:35 app1_01.dbf
- -rw-r----- 1 oracle oinstall 9846784 Jan 7 09:36 control01.ctl
- .............................
- sys@DENVER> SELECT * FROM v$recover_file;
- no rows selected
- sys@DENVER> col name format a50
- sys@DENVER> SELECT file#, name FROM v$datafile ORDER BY 1;
- FILE# NAME
- ---------- --------------------------------------------------
- 1 /u01/oradata/md/system01.dbf
- 2 /u01/oradata/md/sysaux01.dbf
- 3 /u01/oradata/md/undotbs01.dbf
- 4 /u01/oradata/md/users01.dbf
- 5 /u01/oradata/md/example01.dbf
- 6 /u01/oradata/md/perfstat_01.dbf
- 7 /u01/oradata/md/user02.dbf
- 8 /u01/oradata/md/tools01.dbf
- 9 /u01/oradata/md/app1_01.dbf
- 10 /u01/oradata/md/app02_01.dbf
- 10 rows selected.
- sys@DENVER> alter database datafile 10 offline;
- Database altered.
- sys@DENVER> alter database create datafile '/u01/oradata/md/app02_01.dbf';
- Database altered.
- sys@DENVER> select * from user1.t2;
- select * from user1.t2
- *
- ERROR at line 1:
- ORA-00376: file 10 cannot be read at this time
- ORA-01110: data file 10: '/u01/oradata/md/app02_01.dbf'
- sys@DENVER> recover datafile 10;
- Media recovery complete.
- sys@DENVER> alter database datafile 10 online;
- Database altered.
- sys@DENVER> select * from user1.t2;
- ID NAME
- ---------- --------------------------------------------------
- 0 recvery 4
- 1 test
- sys@DENVER>
