当访问到损坏的数据块时,数据库会抛出“ORA-01578: ORACLE data block corrupted”错误,如下:
SQL> select * from t01 where object_id=13246;
ERROR:
ORA-01578: ORACLE data block corrupted (file # 4, block # 310)
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'
可以利用RMAN的recover命令在数据库保持open的状态下恢复受损的数据块(当然前提是有备份和归档):
RMAN> recover datafile 4 block 310 ;
或rman>blockrecover datafile 4 block 310;
Starting recover at 02-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 device type=DISK
channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/backup/full_ORCL_20121202_15_1.bak
channel ORA_DISK_1: piece handle=/u01/app/oracle/backup/full_ORCL_20121202_15_1.bak tag=TAG20121202T144203
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 02-DEC-12
恢复完成,再次执行该查询没有抛出错误信息。
mso-hansi-font-family:Calibri;color:red;mso-no-proof:yes">
数据块损坏还可以通过以下方法处理:
A.查询数据块上的对象
Sql>select segment_name ,segment_type from dba_extents where file_id=4 and 310 between block_id and block_id+blocks-1
B.通过判断定位方法
如果是索引,直接重新创建索引
Sql>alter index ind_name rebuild;
如果是表,那么如下:
看看有没有数据库全备份,如果有,那么根据rman blockrecover来回复
如果没有备份,那么只能坏块数据丢失了,通过设置如下参数,然后把表导出,然后删除掉表,导入
Sql>alter system set events ‘10231 trace name context level 10’;
然后exp表,drop表,导入表