|
数据块及其中数据的挽救
现象:执行ORACLE操作时出现ORA-01578错误
分析:ORA-1578错误是当ORACLE认为一个数据块可能被破坏而发生的,通常引起该错误的原因有以下几种:
I/O的硬件或firmware损坏
操作系统I/O或cache故障
内存或页交换出错
部分数据文件被覆盖
试图访问未格式化块
磁盘修复
其他原因
解决步骤:
查看log以及trace文件,检查是否有其他错误发生
定位错误:
sql>select * from v$datafile where file#=<F>;
sql>select owner,segment_name,segment_type from dba_extents where file_id=<F> and <B> between block_id and block_id+blocks-1;
基于返回的segment_type:
segment类型为temporary或cache或无返回值,检查SQL语句是否正确。
segment类型为rollback segment,则数据块需要恢复。
segment类型为index,检查其所在的表。重建索引即可。
sql> select owner,table_name from dba_tables where cluster_name = name_of_segment
仍然出现1578错误,数据库需要恢复。
segment类型为表,拯救表中的数据。
分析一个实体是否有永久性数据破坏
sql> analyze table table.name validate structure cascade;
sql> analyze table clustername validate structure cascade;
硬件错误的恢复
数据库运行在ARCHIVE模式下
OFFLINE相应的数据文件
拷贝备份的数据文件
rename the datafile to new location
recover the datafile using archive log
online数据文件
数据库运行在非ARCHIVE模式下
OFFLINE相应数据文件
拷贝备份的数据文件,rename the datafile and online it
拯救表中数据
例如:sql>select * from bigemp;
ERROR:ORA-01578: ORACLE DATA block corrupted (file#8,block#8147) ORA-00110: data file 8: ‘/oracle/usr714.dbf’ … … corrupt file id : 8=8(hex) corrupt block id : 8147=1fd3(hex) first rowid in the corrupt block: 0000.1fd3.0000.0008 last rowid in the corrupt block: 0000.1fd2.7fff.0008 first rowid affer this block: 0000.1fd4.0000.0008
sql > create table temp as select * from bigemp where 1=2;
sql > insert into temp select * from bigemp /*+rowid(bigemp) */ where rowid >=’0000.1fd4.0000.0008’;
sql > insert into temp select * from bigemp where rowid <=’0000.1fd2.7fff.0008’;
在ORACLE 7.1以前版本,rowid range scan不存在时,可以通过索引达到以上相同的目的。 |
|