Oracle数据文件有时候因为某种原因会导致损坏而导致无法启动数据库,那如何恢复呢?
下面是一次模拟实验,如下
1. 首先创建一个表空间TEST,在创建一个表test在表空间test上
SQL> create tablespace test datafile '/u01/app/oracle/oradata/lhz/test01.dbf' size 10M;
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. 然后用vi编辑数据文件
[oracle@odb1 ~]$ vi /u01/app/oracle/oradata/lhz/test01.dbf
3.随便输入什么字符,保存
4.关闭数据库实例
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
5.启动实例
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'
看到报错信息数据文件不能验证或锁定数据文件