Kamran Agayev's Oracle Blog

Oracle Certified Master

Manually corrupting the data block in Linux and recovering it using BLOCKRECOVER command of RMAN

Posted by Kamran Agayev A. on March 1st, 2010

Sometimes, in order to test the RMAN’s  BLOCKRECOVER command, we need to corrupt the specific data block and recover it for testing purpose. To do it in Linux, use dd command. In the following example, let’s create a table and corrupt it manually (Don’t try it on the production database :) or you’ll be retired from the job )

SQL> CREATE TABLE corruption_test (id NUMBER);
Table created.

SQL> INSERT INTO corruption_test VALUES(1);
1 row created.

Commit complete.

SQL> SELECT * FROM corruption_test;

SQL> SELECT header_block FROM dba_segments WHERE segment_name=’CORRUPTION_TEST’;

[oracle@localhost ~]$ dd of=/u02/oradata/orcl/users01.dbf bs=8192 conv=notrunc seek=68 << EOF
> testing corruption
0+1 records in
0+1 records out

System altered.

SQL> SELECT * FROM corruption_test;
select * from corruption_test
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 68)
ORA-01110: data file 4: ‘/u02/oradata/orcl/users01.dbf’

Now connect to the RMAN and recover the data block (not the whole datafile or database) using BLOCKRECOVER command as follows:


Starting blockrecover at 01-MAR-10

<… output trimmed … >
<… output trimmed … >

Finished blockrecover at 01-MAR-10

RMAN> exit

Connect to SQL*Plus and query the table:
SQL> SELECT * FROM corruption_test;



11 Responses to “Manually corrupting the data block in Linux and recovering it using BLOCKRECOVER command of RMAN”

  1. Mark Bobak Says:

    What to do if your database uses ASM storage?

  2. Kamran Agayev A. Says:

    Haven’t tested Mark :)

  3. Ulfat Says:

    Kamran thanks!!!
    Perfect example, no comment.

  4. Kamran Agayev A. Says:

    You’re welcome Ulfet

  5. Aijaz Khan Says:

    Hi Kamran,

    How are you?

    I would like to know some good material to learn for the beginners in Oracle DBA.

    I am a beginner in this field having trying to gain knowledge on oracle dba.

    Recently i have completed my oracle dba 11g course from one of a institute and try to do lot of practice on it.

    i wanted to know how actual the dba task is in live project in real time.

    If you let me know some good material or any good exercise by which i can go step by step to improve in my dba field.

    Please let me know.

    Best regards,

    Aijaz Khan

  6. Aijaz Khan Says:

    2.Aijaz Khan said
    March 28, 2010 at 6:39 pm
    Here i would like to ask you somethg on undo tablespace.

    SYS>> Sho parameter undo

    here what i want to know is how i will receive an error ora 01555 in this example i tried to do it many times but i am not receiving any error. I am working on oracle 11g on redhat linux 4 on VMware.

    Which parameter i should mention first on paramter file i.e. init.ora for testing undo tablespace.


    SYS>> sho Parameter undo

    sys>> select tablespace_name, contents, retention from dba_tablespace;

    by default undo tablespace is Noguarantee.

    Here i am creating one small undo tablespace by name Undo1

    sys>> create undo tablespace undo1 datafile ‘/disk2/oradata/suman/undo1.dbf’ size 4m;

    sys>> sho parameter undo

    by default it is undotbs

    Now i want to active the recent undo1 tablespace from undotbs to undo1

    sys>> alter system set undo_tablespace=undo1;

    sys>> sho parameter undo

    now the active undo tablespace is undo1

    now i am connecting to a user by name user1


    here i am creating some sample tables.

    user1>> @$ORACLE_HOME/Sqlplus/demo/demobld

    user1>> select * from emp;

    14 records;

    user1>> insert into emp select * from emp;

    now i create here a loop in order to update this statement continuously in order to fill the undo1 tablespace.

    update emp set sal=2000 where empno=7566;
    end loop;

    now here to the another session and try to retrieve the data.

    sys>> select * from u1.emp;

    if somebody wants to do the transaction since the session is very big and overwritten the earlier one then it raises an error ORA-01555.

    i wanted to know how to do it step by step i am doing the same steps but not receiving the exact error can you plz help me out in this situation how to face this problem in real time experience.

    Best regards,

    Aijaz Khan

  7. Randyl Pulma Says:

    Hi Kamran,

    Good Day!

    I am trying this activity at home. However, I am stuck in this command because I am trying to do this in wondows 7. Can you please give the equivalent command of this for windows platform?

    [oracle@localhost admin]$ dd of=/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf bs=8192 conv=notrunc seek=60 < corruption
    > EOF
    0+1 records in
    0+1 records out

    Greatly appreciate it.


    Best Regards,

    Randyl V. Pulma

  8. Kamran Agayev A. Says:

    Dear Randyl

    For this, you need to use any hexadecimal editor. I’ve shown it on the following video tutorial on “Corrupting data block on Windows OS”

  9. Randyl Pulma Says:

    Hi Kamran,

    Thanks a lot! This is a great help for me as an aspiring DBA.


  10. Ceyhun Says:

    Hi Kamran!

    It was helpfull for me.. Thanks u a lot

  11. Kamran Agayev A. Says:

    Thanks for the feedback Ceyhun. Glad it helped!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>