table data block corruption simulation
1. corrupt the data file corresponding to the table
For this purpose, a dd command is generate from the Oracle views.
set heading off set lines 113 SELECT 'dd of=' || f.file_name || ' bs=8192 conv=notrunc seek=' || to_number(S.HEADER_BLOCK + 1) || ' << EOF', 'CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt ', 'EOF' FROM DBA_SEGMENTS S, dba_data_files f, dba_tables t WHERE f.tablespace_name = t.tablespace_name and S.SEGMENT_NAME = t.table_name and t.table_name = 'BTEST' and S.OWNER = t.owner and t.owner = 'SYS';
After executing this dd comand, the storage space of table sys.btest will be corrupted.
2. flush the buffer cache, so the next querying statement will read data from storage.
alter system flush buffer_cache;
3. select should be error.
sys@ORCL> select * from btest;
select * from btest
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 16, block # 12)
ORA-01110: data file 16: '/opt/oracle/oradata/orcl/ORCL/datafile/o1_mf_broken_2vjk5vss_.dbf'
4. After shutdown and startup, the database functions normal, but the btest will be unavailable.
