Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
When true, Oracle performs block checks for all data blocks making sure that all data in the block
is consistent. Block checking provides early detection of block corruption, however, it costs
between 1-10% in overhead on the database. The more block writes that occur on a system
(INSERT, UPDATE, DELETE), the more costly it becomes. Any errors encountered by block
checking result in an ORA-600 level message. Before setting this parameter to TRUE, first
execute dbv against the datafiles to make sure they are free of corruption. Even when FALSE,
Oracle still provides block checking for the system tablespace.
Handling Corruption
Some errors reported by dbv are transient in nature. Therefore, the utility should be executed on
the suspect file again to confirm block corruption. If problems are again reported in the same
page locations, then the file is indeed corrupt.
Once one or more corrupted blocks are detected, below are some options available to address
block corruption:
1. Drop and re-create the corrupted object If the loss of data is not an issue, this is the preferred
approach. For Data Warehouses, the data can be reloaded from external sources and the loss of
data is minor. However, for OLTP tables (customer_orders), no data can be lost without a serious
negative impact on the business.
If the object is an index, rebuild it. If a few blocks are corrupt, determine which object(s) are
causing the corruption. This can be done in the query below by mapping the physical file location
to an object(s) contained in the file.
select tablespace_name, segment_type, owner, segment_name from DBA_EXTENTS where
file_id = and between block_id AND block_id + blocks-1;
2. Restore the file from a backup The tried and true method for restoring good blocks back into
the datafiles.
DBMS_REPAIR Dealing with block corruption is always a risky proposition so limit the use of
DBMS_REPAIR to extreme situations. DBMS_REPAIR is a package supplied by Oracle that
identifies and repairs block corruption (described in next section).
If options 1 and 2 are unacceptable, using DBMS_REPAIR can resolve some block corruption
issues.
dbv is a useful utility to inspect datafiles for block corruption. It should be used primarily against
offline datafiles on a regular basis. In should be used in combination with other corruption
detection mechanisms, including the analyze table command and pfile parameters.
For online checking, the parameter db_block_checking should be enabled, provided the overhead
incurred on the database is at an acceptable level. Finally, when corrupted blocks are detected,
choose the most appropriate method of recovery be it a restore, a rebuild of the object, or
utilizing the DBMS_REPAIR utility.
Automating dbv
dbv utility can be automating and executed on a regular basis. The following shell script (dbv.ksh)
prompts for Oracle environment information, connects to the database, and produces a command
file that can be executed when needed. In this script, dbv is executed immediately after its
generated.
#!/bin/ksh
# Oracle Utilities
# dbv automation script
#
#
. oraenv
wlogfile=dbv.${ORACLE_SID}
SQLPLUS=${ORACLE_HOME}/bin/sqlplus
$SQLPLUS -s system/manager >> $wlogfile <<EOF
set echo off feedback off verify off pages 0 termout off
linesize 150
spool dbv.cmd
select 'dbv file=' || name || ' blocksize=' || block_size ||
' feedback=' || round(blocks*.10,0) -- 10 dots per file
from v\$datafile;
spool off
set feedback on verify on pages24 echo on termout on
EOF
ksh dbv.cmd
#
# End of script
The dbv.ksh script formats a dbv command that can be executed from the UNIX command line.
The logfile for the script is dbv.${ORACLE_SID}.
The results of the SQL statement are placed in the dbv.cmd file and this file is executed at the
end of the script. Notice that a feedback was specified equivalent to one dot per each 10 percent
of the file processed, in order to provide a status of dbv.
The contents of the dbv.cmd file are:
$ cat dbv.cmd
dbv file=/usr/oracle/asg920xr/datafiles/ASG920xrsys.dbf blocksize=8192 feedback=3200
dbv file=/usr/oracle/asg920xr/datafiles/undo.dbf blocksize=8192 feedback=1088
dbv file=/usr/oracle/asg920xr/datafiles/ASG920xray.dbf blocksize=8192 feedback=3200
dbv file=/usr/oracle/asg920xr/datafiles/aaa/UNDO1.dbf blocksize=8192 feedback=124
dbv file=/usr/oracle/asg920xr/datafiles/bbb/UNDO2.dbf blocksize=8192 feedback=26
dbv file=/usr/oracle/asg920xr/datafiles/ccc/UNDO3.dbf blocksize=8192 feedback=38
dbv file=/usr/oracle/asg920xr/datafiles/ddd/UNDO4.dbf blocksize=8192 feedback=51
dbv file=/usr/oracle/asg920xr/datafiles/aaa/UNDO5.dbf blocksize=8192 feedback=64
dbv file=/usr/oracle/asg920xr/datafiles/zzz/UNDO6.dbf blocksize=8192 feedback=13
dbv file=/usr/oracle/asg920xr/datafiles/aaa/undo_all1.dbf blocksize=8192 feedback=576
dbv file=/usr/oracle/asg920xr/datafiles/bbb/undo_all2.dbf blocksize=8192 feedback=26
dbv file=/usr/oracle/asg920xr/datafiles/ccc/undo_all3.dbf blocksize=8192 feedback=499
dbv file=/usr/oracle/asg920xr/datafiles/ddd/undo_all4.dbf blocksize=8192 feedback=602
dbv file=/usr/oracle/asg920xr/datafiles/aaa/undo_all5.dbf blocksize=8192 feedback=614
dbv file=/usr/oracle/asg920xr/datafiles/zzz/undo_all6.dbf blocksize=8192 feedback=13
dbv file=/data1/dbxray/datafiles/undo_all7.dbf blocksize=8192 feedback=602
dbv file=/data1/dbxray /datafiles/undo_tablespace_long2.dbf blocksize=8192 feedback=166
dbv file=/usr/oracle/asg920xr/datafiles/symbolic/UNDO8.dbf blocksize=8192 feedback=13
dbv file=/usr/oracle/asg920xr/datafiles/zzz/UNDO6a.dbf blocksize=8192feedback=1
dbv file=/usr/oracle/asg920xr/datafiles/davetest.dbf blocksize=8192 feedback=26
Notice in the dbv.cmd file above that the block_size is included for each datafile. In Oracle
versions 8.1.7 and below, the following command would indicate the blocksize since it had to be
consistent across the database.
SQ> show parameter db_block_size
NAME
TYPE
VALUE