You are on page 1of 3

001 SQL> CREATE USER usr IDENTIFIED BY usr;

002 User created.


003
004 SQL> GRANT DBA TO usr;
005 Grant succeeded.
006
007 SQL> CONN usr/usr
008 Connected.
009 SQL> CREATE TABLE tbl_corrupt_test (id NUMBER);
010 Table created.
011
012 SQL> INSERT INTO tbl_corrupt_test VALUES(1);
013 1 row created.
014
015 SQL> COMMIT;
016 Commit complete.
017
018 SQL> COLUMN segment_name FORMAT a45
019
020 SQL> SELECT segment_name, tablespace_name from dba_segments WHERE segmen
t_name='TBL_CORRUPT_TEST';
021
022 SEGMENT_NAME TABLESPACE_NAME
023 --------------------------------------------- --------------------------
----
024 TBL_CORRUPT_TEST USERS
025
026 SQL> COLUMN segment_name FORMAT a15
027 SQL> COLUMN tablespace_name FORMAT a15
028 SQL> COLUMN name FORMAT a45
029
030 SQL> SELECT segment_name, a.tablespace_name, b.name FROM dba_segments a,
v$datafile b
031 WHERE a.header_file=b.file# AND a.segment_name='TBL_CORRUPT_TEST';
032 SEGMENT_NAME TABLESPACE_NAME NAME
033 --------------- --------------- -----------------------------------
034 TBL_CORRUPT_TEST USERS /u01/oracle/product/10.2.0/db_1/oradata/newdb/use
rs01.dbf
035 SQL> ALTER TABLESPACE users BEGIN BACKUP;
036
037 Tablespace altered.
038
039 SQL> host cp /u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf /
u01/oracle/product/10.2.0/db_1/oradata/newdb/users01_backup.dbf
040
041 SQL> ALTER TABLESPACE users END BACKUP;
042
043 Tablespace altered.
044
045 SQL> SELECT header_block FROM dba_segments WHERE segment_name='TBL_CORRU
PT_TEST';
046
047 HEADER_BLOCK
048 ------------
049 59
050
051 [oracle@localhost admin]$ dd of=/u01/oracle/product/10.2.0/db_1/oradata/
newdb/users01.dbf bs=8192 conv=notrunc seek=60 <<EOF
052 > corruption
053 > EOF
054 0+1 records in
055 0+1 records out
056
057 [oracle@localhost admin]$ sqlplus /nolog
058
059 SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 9 03:35:32 2010
060
061 Copyright (c) 1982, 2005, Oracle. All rights reserved.
062
063 SQL> CONN usr/usr
064 Connected.
065
066 SQL> ALTER SYSTEM FLUSH BUFFER_CACHE;
067
068 System altered.
069
070 SQL> SELECT * FROM tbl_corrupt_test;
071 SELECT * FROM tbl_corrupt_test
072 *
073 ERROR at line 1:
074 ORA-01578: ORACLE data block corrupted (file # 4, block # 60)
075 ORA-01110: data file 4:
076 '/u01/oracle/product/10.2.0/db_1/oradata/newdb/users01.dbf'
077 SQL> EXIT
078
079 [oracle@localhost admin]$ rman target sys
080
081 Recovery Manager: Release 10.2.0.1.0 - Production on Tue Mar 9 03:35:58
2010
082
083 Copyright (c) 1982, 2005, Oracle. All rights reserved.
084
085 target database Password:
086 connected to target database: NEWDB (DBID=2953562798)
087
088 RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 60;
089
090 Starting blockrecover at 09-MAR-10
091 using target database control file instead of recovery catalog
092 allocated channel: ORA_DISK_1
093 channel ORA_DISK_1: sid=159 devtype=DISK
094
095 RMAN-00571: ===========================================================
096 RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
097 RMAN-00571: ===========================================================
098 RMAN-03002: failure of blockrecover command at 03/09/2010 03:36:13
099 RMAN-06026: some targets not found - aborting restore
100 RMAN-06023: no backup or copy of datafile 4 found to restore
101
102 RMAN> CATALOG DATAFILECOPY '/u01/oracle/product/10.2.0/db_1/oradata/newd
b/users01_backup.dbf';
103
104 cataloged datafile copy
105 datafile copy filename=/u01/oracle/product/10.2.0/db_1/oradata/newdb/use
rs01_backup.dbf recid=1 stamp=713158624
106
107 RMAN> BLOCKRECOVER DATAFILE 4 BLOCK 60;
108
109 Starting blockrecover at 09-MAR-10
110 using channel ORA_DISK_1
111
112 channel ORA_DISK_1: restoring block(s) from datafile copy /u01/oracle/pr
oduct/10.2.0/db_1/oradata/newdb/users01_backup.dbf
113
114 starting media recovery
115 media recovery complete, elapsed time: 00:00:03
116
117 Finished blockrecover at 09-MAR-10
118
119 RMAN> EXIT
120
121 Recovery Manager complete.
122 [oracle@localhost admin]$ sqlplus /nolog
123
124 SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 9 03:37:28 2010
125
126 Copyright (c) 1982, 2005, Oracle. All rights reserved.
127 SQL> CONN usr/usr
128 Connected.
129 SQL> SELECT * FROM tbl_corrupt_test;
130
131 ID
132 ----------
133 1
134
135 SQL>

You might also like