The below command is showing how to corrupt an oracle block for the purpose of testing the RMAN block recovery features.

First, I should find a block that will be corrupted. For this, I am using below sql.

SQL> select a.file_name,d.header_block, d.blocks
from dba_segments d, dba_data_files a
where a.file_id=d.header_file and  d.segment_name=’TESTTBL’ ;

FILE_NAME                              HEADER_BLOCK     BLOCKS
————————————-  ————     ——
/u02/oracle/oradata/ORCL/mytbs01.dbf             11      27648


Here you should not corrupt the header block 1 because RMAN cannot perform block level recovery on 1th block (datafile header) of the datafile.

For example I want to corrupt 15th block of mytbs01.dbf:

$ dd if=/dev/zero of=/u02/oracle/oradata/ORCL/mytbs01.dbf bs=8k conv=notrunc seek=15 count=1;

1+0 records in
1+0 records out
8192 bytes (8.2 kB) copied, 0.0186921 seconds, 438 kB/s


Let’s verify corrupted block:

$ dbv file=/u02/oracle/oradata/ORCL/mytbs01.dbf blocksize=8192

DBVERIFY – Verification starting : FILE = /u02/oracle/oradata/ORCL/mytbs01.dbf
Page 15 is marked corrupt
Corrupt block relative dba: 0x0200000f (file 8, block 15)
Completely zero block found during dbv:

DBVERIFY – Verification complete

Total Pages Examined         : 6400
Total Pages Processed (Data) : 5824
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 574
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 1
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Highest block SCN            : 1313502 (0.1313502)