How to check Corruption in Database Using DBVERIFY

The primary tool for checking for corruption in an Oracle database is DBVERIFY. It can be used to perform a physical data structure integrity check on data files whether the database is online or offline. The big benefit of this is that DBVERIFY can be used to check backup data files without adding load to the database server. You invoke DBVERIFY from the operating system command line like this:
$ dbv file=data01.dbf logfile=verify.log blocksize=8192 feedback=100
In this example data01.dbf is the data file to check, and the tablespace this file belongs to has a block size of 8192 bytes. The feedback parameter tells DBVERIFY to draw a period on the screen after every 100 pages (blocks) of the file are verified.
In the log file you’ll see output like this:

DBVERIFY – Verification starting : FILE = data01.dbf

DBVERIFY – Verification complete

Total Pages Examined : 640
Total Pages Processed (Data) : 631
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 9
Total Pages Empty : 0
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
The Total Pages Failing values show the number of blocks that failed either the data block or index block checking routine. The Total Pages Marked Corrupt figure shows the number of blocks for which the cache header is invalid, thereby making it impossible for DBVERIFY to identify the block type. And the Total Pages Influx is the number of blocks for which DBVERIFY could not get a consistent image. (This could happen if the database is open when DBVERIFY is run. DBVERIFY reads blocks multiple times to try to get a consistent image, but DBVERIFY cannot get a consistent image of pages that are in flux.)
If you want to verify only a portion of a data file, you can specify a starting and ending block when running DBVERIFY. If you want to verify the entire database, you can generate a short shell script to run DBVERIFY on every data file in the database. You can do this easily using SQL*Plus:

SQL> SPOOL dbv_on_all_files.sh
SQL> SELECT ‘dbv file=’ || file_name ||
2 ‘ logfile=file’ || ROWNUM ||
3 ‘.log blocksize=8192’
4 FROM dba_data_files;
SQL> SPOOL OFF
After running the shell script you can quickly scan all of the DBVERIFY log files with Unix commands like:
$ grep Failing file*.log
$ grep Corrupt file*.log
$ grep Influx file*.log
You can also use DBVERIFY to validate a single data or index segment. To do this you must be logged onto the database with SYSDBA privileges. During the verification the segment is locked; if the segment is an index then the parent table is also locked.
There are other ways to check for database corruption besides DBVERIFY. You can take a full database export, with the dump file optionally specified as a null device. This will read every row in every user table in the database, discovering any corrupted data blocks along the way. However, this technique does not access every index entry or the entire data dictionary.

If you want to check one table and all of its indexes, you can use the ANALYZE statement to read every row of the table, read every entry in each of the table’s indexes, and make sure the table and index data are consistent with each other:

SQL> ANALYZE TABLE emp VALIDATE STRUCTURE CASCADE;
This will lock the table, preventing DML on the table, unless you specify the ONLINE keyword. Online validation reduces the amount of validation performed to allow for concurrency.
There are several ways to check for corruption in an Oracle database, but the DBVERIFY tool is the most versatile. DBVERIFY does not limit concurrency or DML while it is running, and it can be run against a database backup. Just remember that if DBVERIFY detects corruption in your database and you are planning to recover the corrupt file from a backup, you should perform a DBVERIFY validation on the backup file before beginning the recovery. This will tell you if the corruption exists in the backup also.

Did you get a chance to download Free Interview Questions related to Database? If not, download it here http://k21academy.com/oracle-dba-12c-interview-question

Database interview questions

About the Author Rajat

I am Rajat Dey and I have more than decade of Oracle experience from all major regions throughout the globe. I am well versed in most facets of Oracle, supporting database, fusion middleware and the eBusiness suite across many operating system platforms.Currently I am located in Sydney  Oracle Financials 11i and Release 12,12.2  Oracle RDBMS 7x,8i , 9i,10g and 11g  Amazon cloud .  Oracle RAC 10g and 11g  Oracle Applications Server  Oracle Web logic Server  OBIEE  Hyperion  SSO  Oracle Portal  PL/SQL  UNIX  SQL  MS-SQL 2008.  OEM 12c .  Data Guard .  Essbase .  Database backup and recovery.  Performance Tunning.  TimeSten

Leave a Comment:

17 comments
prajwal says July 4, 2008

excellent topic..
rajat..I appreciate your knowledge…..

Reply
anonnymous says July 4, 2008

Rajat,

I have an issue of block corruption with my system tablespace and impacted table is part of sys schema i.e, argument$.

I open a service request with Oracle support and they said they can not help on this as manipulation with sys schema is not allowed and you need backup your data using export and import. I follwed all the steps same like your post also ran the admin repair package but not resolved. As you have very good experience with block experience can you please help me.

Reply
mohammed says July 5, 2008

Good one,

Thanks Rajat,

Mohammed Yousuf
Sr.Oracle DBA
IBM, Bangalore.

Reply
Rajat says July 5, 2008

Hi ,

I am not sure .. As per my knowledge … if system tables get coorupted we need to recover database from Hot backup/cold … But u can try this metallink Doc , that may help u .
Doc ID: Note:68013.1

Reply
anonnymous says July 5, 2008

Rajat,

I resolved the issue today. Thanks for metalink note , I already used that but no help.

I closed my service request.

Reply
Geetha M says July 5, 2008

Hi Rajat

Congratulations for an informative topic on db corruption.

Why does db get corrupted, any specific reasons for it, if yes how could we avoid it in prior.

Thanks in Advance.

Rgds

Reply
lakshmikanthan says July 7, 2008

Hi Rajat
Thanks for giving valuable information
I congratulate to u
Thanks
lakshmikanthan

Reply
Rajat says July 7, 2008

Geetha M ,

Its happen due to certain reasons some of them are System Memory ,Disk controller (Bad I/O hardware ,RAID controller),Disk Device (Problem with the device driver ).

The best way to resolve those issue is keep the backup updated.

Reply
Geetha M says July 7, 2008

thank you Rajat!!

Reply
Saurabh Sood says July 10, 2008

Just to add, DBV only check for the physical corruptions in the database, not for logical corruptions.

It will detect ora-1578 errors but will not be able to find ora-8103 errors which are due to logical corruption in database.

Reply
Ramnik Gupta says July 12, 2008

Hi All,
My taken on this:

Block corruption is while the data is being written to the data blocks, if the write to the block fails abruptly, which means there is a partial write in the block, may be because of power disruption or I/O problem, leaving no time for header to be updated, or row data to be populated, oracle leaves the block corrupt.In case of block corruption you can normally use the database unless you try to read that particular block, against which it shoots up the block corruption error.Generally block corruption occurs if write fails on the block, when the transaction is being committedYou can find detail information about block corruption in alert.log file

block corruption can happens at

1)Physical Level corruption (which means media corrupt)
2)Logical Level corruption (which means soft corrupt)

Physical corruption can be caused by defected memory boards, controllers or broken sectors on a hard disk;

Logical corruption can among other reasons be caused by an attempt to recover through a NOLOGGING action.

To Differetiate between both the corruption levels (logical and physical)

Logical corruption is header – footer – that is one of the checks, yes (it is looking for fractured blocks and when it hits one, it’ll re-read it, that is why there is no need for “alter tablespace begin backup” with rman)

Physical corruption is “we cannot read the block from disk, something is physically preventing us from doing so”

The methods to detect Block corruptions are

1) DBVerify utility
2) Block checking parameters (DB_BLOCK_CHCEKSUM) – In Oracle 10g db_block_checksum value TYPICAL which should be TRUE
and db_block_checking value FULL should be TRUE.
3) ANALYZE TABLE tablename VALIDATE STRUCTURE CASCADE SQL statement
4) RMAN BACKUP command with THE VALIDATE option

Regards
Ramnik Gupta

Reply
Preetam says September 7, 2009

Good One,Cheers

Preetam dash
TCS,kolkata

Reply
Mohammed Saleem says January 14, 2010

Good one,

Thanks Rajat,

Mohammed Saleem
Sr Oracle DBA
Sun Microsystems,Chennai

Reply
pAnkAj says July 30, 2010

Hi Rajat,
Thanks for this valuable information, its really helpful. You are really good one.

Best of Regards,
Pankaj
Oracle DBA,
Emsang Technology, chennai

Reply
Bharat Varandani says July 12, 2012

Hi rajat sir,
m very thank full to you b’caz of very important topic dbv, m ocp and m searching a oracle dba jobs.. M nt dba bt its very amzing topic and its gud for my knowledge.
Thnx sir for gud topic nd experince.

Reply
Salim Zaffar says September 30, 2012

Thanks to Mr (Rajat and Ramnik) for sharing valuable info

Reply
Ravin Maharaj says June 8, 2017

How do run dbverify against datafiles stored in ASM?

Reply
Add Your Reply