Wednesday, April 29, 2009

Database Verify Utilily (dbv) in Oracle Database

The Database verify utility is mechanism to check the block corruption of the oracle datafiles at Operating system level. It validate the blocks specified by the dbv utility parameters and generates output accordingly. dbv utility is generally useful
for verifying and validating online as well as offline datafiles. Generally this procedure is not used for online data files as errors may be induced in the online files during the execution of validating the files and successive checks may be needed. The Database utiliy can be executed as below

dbv file=datafile_name blocksize=datafile_blocksize

It is the duty of Database administrator to check the file corruption at frequent basis. Below is the script that generates the script for the checks required for the datafiles in unix enviornment and executes the same at the end of the generation

#!/bin/ksh
# dbv script in unix enviornement
#
SQLPLUS=${ORACLE_HOME}/bin/sqlplus
wlogfile=dbv.${ORACLE_SID}
echo "connecting to oracle database and generating commands"
$SQLPLUS system/manager >>$wlogfile << EOF
set echo off feedback off verify off pages 0 termout off
set linesize 150
spool dbv.cmd
select 'dbv file=' || name || ' blocksize=' || block_size ||' feedback=' || round(blocks*.10,0) from v\$datafile;
spool off
set feedback on verify on pages24 echo on termout on
EOF
echo "command generated succesfully"
echo "verifying datafiles
ksh dbv.cmd
#End

The verification would end up as below

DBVERIFY - Verification complete

Total Pages Examined : 61440
Total Pages Processed (Data) : 995
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 1
Total Pages Empty : 60444
Total Pages Marked Corrupt : 0
Total Pages Influx : 0

Summary of the verification

Total Pages Examined : number of pages examined
Total Pages Processed (Data) : number of pages inspected that contained table data
Total Pages Failing (Data) : number of table blocks that have corruption
Total Pages Processed (Index): number of blocks inspected by dbv that contained index data
Total Pages Failing (Index): number of index blocks that are corrupted
Total Pages Processed (Other): number of blocks processed other than table and indexes that are corrupted
Total Pages Empty : number of unused blocks in the file
Total Pages Marked Corrupt : show the number of corrupt blocks during scan if it is non zero there is error in the datafile
Total Pages Influx : number of blocks rechecked due to the blocks in use