You are on page 1of 3

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

1)
Modified: Jun 25, 2013 Type: SAMPLE CODE
In this Document
APPLIES TO:
Oracle Database - Enterprise Edition - Version 7.3.0.0 and later
Information in this document applies to any platform.
***Checked for relevance on 25-Jun-2013***
PURPOSE
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.
REQUIREMENTS
We need to have the database at least in MOUNT stage to perform this operation.
CONFIGURING
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.
INSTRUCTIONS
As a first step run the following script from sqlplus which will generate the script for DBV.
Purpose
Requirements
Configuring
Instructions
Sample Code
Sample Output
References
mkdir /tmp/dbvlogs
cd /tmp/dbvlogs
Page 1 of 3 Document Display
6/3/2014 https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=w8j7amlnj_111
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.
CAUTION
----- 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/dbvchk.sh
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.
SAMPLE CODE
Now you need to run the dbv commands for all the datafiles, which is spooled to dbvchk.sh.
Page 2 of 3 Document Display
6/3/2014 https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=w8j7amlnj_111
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
windows.
If you have a Service Request logged, then compress the log files, upload the above compressed file to
metalink.
In case of a Windows operating system, simply use the a zip utility (7-Zip or Winzip) to compress the
files.
SAMPLE OUTPUT
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.
/tmp/dbvlogs/system.dbf.1.log
REFERENCES
NOTE:35512.1 - DBVERIFY - Database file Verification Utility (7.3.2 - 11.2)
NOTE:403747.1 - FAQ: Physical Corruption
$ cd /tmp/dbvlogs
$ chmod 755 dbvchk.sh
$ ./dbvchk.sh
$ tar cvf dbvlogs.tar *.log
$ compress dbvlogs.tar.Z
Page 3 of 3 Document Display
6/3/2014 https://support.oracle.com/epmos/faces/SearchDocDisplay?_adf.ctrl-state=w8j7amlnj_111

You might also like