You are on page 1of 3

Script To Run DBV On All Datafiles Of the Database (Doc ID 352907.

Modified: Jun 25, 2013 Type: SAMPLE CODE
In this Document
Oracle Database - Enterprise Edition - Version and later
Information in this document applies to any platform.
***Checked for relevance on 25-Jun-2013***
This script will simplify the task of running DBV against all datafiles of a database.
When a user experiences ORA-01578 / ORA-08103 or any other kind of corrupt messages, this utility can be
used to scan the datafiles at OS level.
We need to have the database at least in MOUNT stage to perform this operation.
Login to your server as the oracle user and create a directory that is going to hold the DBV logs.
In case of Windows, create a directory under relevant drive.
As a first step run the following script from sqlplus which will generate the script for DBV.
Sample Code
Sample Output
mkdir /tmp/dbvlogs
cd /tmp/dbvlogs
Page 1 of 3 Document Display
In case datafiles are on RAW devices, then we need to mention the END parameter in DBV.
You can use the following query in case you are using RAW devices.
In the case of Windows the file separator will be forward slash '\'
Hence we need to replace the backward slash '/' with the forward slash in
the above script.
If ASM storage being used, we need to specify USERID to get authenticated on ASM Instance.
You can use following query if you are running in ASM storage.
----- dbvsql.sql ----------
sqlplus /nolog
connect / as sysdba
set feedback off
set head off
set echo off
set linesize 200
set pagesize 2500
spool /tmp/dbvlogs/
select 'dbv file=' || name || ' blocksize='|| block_size || ' logfile=' ||
substr(name, instr(name, '/', -1, 1) +1) ||
'.' || file# || '.log' from v$datafile
spool off
select 'dbv file='||name||' blocksize='||block_size||' end='||
(bytes/block_size)||' logfile='||
substr (name, instr (name, '/', -1, 1) + 1)||'.'||file#||'.log'
from v$datafile;
-- For Windows the following modification is required
select 'dbv file=' || name || ' blocksize='|| block_size ||
' logfile=' || substr(name, instr(name, '\', -1, 1) +1) ||
'.' || file# || '.log' from v$datafile
select 'dbv file=' || name || ' blocksize='|| block_size || '
USERID=sys/&SYS_PASSWORD logfile=' ||
substr(name, instr(name, '/', -1, 1) +1) ||
'.' || file# || '.log' from v$datafile
This sample code is provided for educational purposes only, and is not supported by Oracle Support. It has
been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in
your test environment before using.
Now you need to run the dbv commands for all the datafiles, which is spooled to
Page 2 of 3 Document Display
Please proof read this script before executing the same.
In case of Windows, just run the above file. It is more appropriate to have a .bat or .cmd extension on
If you have a Service Request logged, then compress the log files, upload the above compressed file to
In case of a Windows operating system, simply use the a zip utility (7-Zip or Winzip) to compress the
As per the above script, the dbv logs will be generated under /tmp/dbvlogs directory.
The files will have the name as follows.
For system datafile with the name /tmp/system.dbf and file# 1 the logfile will have the name like.
NOTE:35512.1 - DBVERIFY - Database file Verification Utility (7.3.2 - 11.2)
NOTE:403747.1 - FAQ: Physical Corruption
$ cd /tmp/dbvlogs
$ chmod 755
$ ./
$ tar cvf dbvlogs.tar *.log
$ compress dbvlogs.tar.Z
Page 3 of 3 Document Display