Re: Data corruption

  • From: Jared Still <jkstill@xxxxxxxxx>
  • To: peterdixon001@xxxxxxxxxxx
  • Date: Mon, 18 Apr 2005 13:20:01 -0700

Here's a method to corrupt a block on linux.
create tablespace corrupt datafile '/u01/oradata/dv03/corrupt.dbf' size 5m 
reuse
extent management local uniform size 8k
/

-- create a table with 2 blocks
create table corrupt_objects
tablespace corrupt
as
select *
from all_objects
where rownum < 70
/

-- get the block id
select segment_type, relative_fno, file_id, extent_id, block_id, blocks
from dba_extents
where segment_name = 'CORRUPT_OBJECTS'
/
14:12:51 rsysdevdb.radisys.com <http://rsysdevdb.radisys.com> - 
js001292@dv03 SQL> @id

SEGMENT_TYPE RELATIVE_FNO FILE_ID EXTENT_ID BLOCK_ID BLOCKS
------------------ ------------ ---------- ---------- ---------- -----------
TABLE 10 10 0 9 2

1 row selected.

#corrupt one block
dd conv=notrunc if=/dev/zero of=/u01/oradata/dv03/corrupt.dbf bs=8192 
seek=10 count=1

-- check for corrupt block
eclare
v_corrupt_count integer;
begin
sys.dbms_repair.check_object (
schema_name => 'JS001292',
object_name => 'CORRUPT_OBJECTS',
repair_table_name => 'REPAIR_TABLE',
object_type => sys.dbms_repair.table_object,
corrupt_count => v_corrupt_count
);

dbms_output.put_line('Corrupt Count: ' || v_corrupt_count);
end;
/
14:16:11 rsysdevdb.radisys.com <http://rsysdevdb.radisys.com> - 
js001292@dv03 SQL> @check
Corrupt Count: 1

PL/SQL procedure successfully completed.

-- examine corruptions
SQL> select schema_name,object_name, corrupt_type
14:18:38 2 from sys.repair_table
14:18:42 3 /


14:18:11 rsysdevdb.radisys.com <http://rsysdevdb.radisys.com> - 
js001292@dv03 SQL> select schema_name,object_name, corrupt_type
14:18:38 2 from sys.repair_table
14:18:42 3 /

SCHEMA_NAME OBJECT NAME CORRUPT_TYPE
------------------------------ ------------------------------ ------------
JS001292 CORRUPT_OBJECTS 6148
JS001292 CORRUPT_OBJECTS 6148

2 rows selected.

14:18:42 rsysdevdb.radisys.com <http://rsysdevdb.radisys.com> - 
js001292@dv03 SQL>

There are 2 rows as I ran this scenario twice.

HTH

Jared





On 4/18/05, Peter Dixon <peterdixon001@xxxxxxxxxxx> wrote:
> 
> I am wanting to test dbs_repair , but I need to corrupt a block within my
> test database.
> 
> Anybody know how to do it?
> 
> --
> //www.freelists.org/webpage/oracle-l
> 



-- 
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist

--
//www.freelists.org/webpage/oracle-l

Other related posts: