Sometimes the database cannot be started because the data file is damaged for some reason. How can this problem be recovered?
The following is a simulated experiment:
1. First create a tablespace TEST, and then create a table test on the tablespace test.
SQL> create tablespace test datafile '/u01/app/oracle/oradata/lhz/test01.dbf' size 10 M;
SQL> create table test as select * from dba_objects;
Table created
SQL> alter table test move tablespace test;
Table altered
SQL> select count (*) from test;
COUNT (*)
----------
50881
2. Then use vi to edit the data file
[Oracle @ odb1 ~] $ Vi/u01/app/oracle/oradata/lhz/test01.dbf
3. Enter any characters and save them.
4. Shut down database instances
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
5. Start the instance
SQL> startup
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 243272768 bytes
Database Buffers 348127232 bytes
Redo Buffers 6287360 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 9-see DBWR trace file
ORA-01110: data file 9: '/u01/app/oracle/oradata/lhz/test01.dbf'
The error message indicates that the data file cannot be verified or the data file cannot be locked.
6. First corrupt data file offline and open the database instance
SQL> alter database datafile '/u01/app/oracle/oradata/lhz/test01.dbf' offline;
Database altered.
SQL> alter database open;
Database altered.
7. Add the same tablespace test
SQL> alter database create datafile '/u01/app/oracle/oradata/lhz/test01.dbf ';
Database altered.
SQL> recover datafile 9;
Media recovery complete.
SQL> alter database datafile 9 online;
Database altered.
8. Verify the recovery result:
SQL> select count (*) from andylhz. test;
COUNT (*)
----------
50881
Recovery completed!
This article is from the "Shadow Knight" blog, please be sure to keep this source http://andylhz2009.blog.51cto.com/728703/1197954