网站建设
联系我们

10g中处理坏块

发布于:2014-02-12 10:07来源:未知 作者:admin 点击:
select name ,checkpoint_change# from v$datafile;
 
[oracle@target ~]$ dbv file=/u01/app/oracle/oradata/orcl/user.dbf
 
--dbv不能验证索引的错误
ANALYZE TABLE table_name VALIDATE STRUCTURE CASCADE;
ANALYZE INDEX index_name VALIDATE STRUCTURE;
 
 
--DBMS_REPAIR应用包
create tablespace qq datafile 'D:\ORACLE\ORADATA\ORA10\QQ.WW' size 256k;
create table scott.t2 tablespace qq as select * from scott.emp;
insert into scott.t2 select * from scott.t2;
将表t2插满,提交。
alter system checkpoint;
编辑数据文件,破坏数据块
 
--建立repair_table表,如果有索引,还要建立一个存放索引坏键值的表。dump_orphan_keys过程
conn / as sysdba
BEGIN
DBMS_REPAIR.ADMIN_TABLES (
table_name => 'REPAIR_TABLE',
table_type => DBMS_REPAIR.REPAIR_TABLE,
action => DBMS_REPAIR.CREATE_ACTION,
tablespace => 'USERS');
END;
/
 
--查找坏块
 
SET SERVEROUTPUT ON
DECLARE num_corrupt INT;
BEGIN
num_corrupt := 0;
DBMS_REPAIR.CHECK_OBJECT(
schema_name => 'SCOTT',
object_name => 'T2',
repair_table_name => 'REPAIR_TABLE',
corrupt_count => num_corrupt);
dbms_output.put_line('发现损坏的块数:'||num_corrupt);
END;
/
 
--修理repair_table中所描述的坏块
SET SERVEROUTPUT ON
DECLARE num_fix INT;
BEGIN
num_fix := 0;
DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
schema_name => 'SCOTT',
object_name => 'T2',
object_type => DBMS_REPAIR.TABLE_OBJECT,
repair_table_name => 'REPAIR_TABLE',
fix_count => num_fix);
dbms_output.put_line('修理损坏的块数:'||num_fix);
END;
/
--跳过坏数据库块
begin
DBMS_REPAIR.SKIP_CORRUPT_BLOCKS(
schema_name => 'SCOTT',
object_name => 'T2',
object_type => DBMS_REPAIR.TABLE_OBJECT);
end;
/
 
--如果你用的是空闲列表模式,还得进一步的处理
exec dbms_repair.rebuild_freelists(schema_name => 'SCOTT',object_name => 'T2');
 
----------------
设置内部事件,使exp跳过这些损坏的block:
ALTER SYSTEM SET EVENTS='10231 trace name context forever,level 10';
 
tag标签:
------分隔线----------------------------
------分隔线----------------------------