The dbverify tool is used to verify the physical structure of the data file.
The main purpose of the dbverify tool is to check the physical structure of the data file, including whether the data file is damaged, whether there are logical Bad blocks, and what types of data contained in the data file.
The dbverify tool can verify online or offline data files. Data files can be accessed regardless of whether the database is opened or not. An example of the simplest way to access a data file:
E: Oracle> DBV file = E: oracleoradataytk92users01. DBF blocksize = 8192
Dbverify: Release 9.2.0.4.0-production on Thursday March 26 21:17:44 2009
Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.
Dbverify-verification starting: file = E: oracleoradataytk92users01. DBF
Dbverify-verification completed
Total number of checked pages: 8160 total number of processed pages (data): 6867 total number of failed pages (data): 0 total number of processed pages (INDEX): 743 total number of failed pages (INDEX): 0 total number of pages processed (other): 270 total number of pages processed (segment): 0 total number of failed pages (segment): 0 total number of blank pages: 280 total number of pages marked as corrupted: 0 total number of pages imported: 0
We can see that the result of dbverify includes the number of blocks included in the data file, including how many data blocks, how many index blocks, and how many empty blocks, number of blocks marked as bad blocks and number of Bad blocks.
For the dbverify tool, the higher version can automatically identify the lower version of the database, for example, the 11g DBV can access the 9i Database:
Dbverify: Release 11.1.0.6.0-production on Thursday March 26 21:34:28 2009
Copyright (c) 1982,200 7, Oracle. All rights reserved.
Dbverify-Start verification: file = E: oracleoradataytk92users01. DBF
Dbverify-verification completed
Total number of checked pages: 8160 total number of processed pages (data): 7192 total number of failed pages (data): 0 total number of processed pages (INDEX): 415 total number of failed pages (INDEX): 0 total number of pages processed (other): 273 total number of pages processed (segment): 0 total number of failed pages (segment): 0 total number of blank pages: 280 total number of pages marked as damaged: 0 total number of inbound pages: 0 total number of encrypted pages: 0 maximum block SCN: 1963808326 (1.1963808326)
However, when DBV of a lower version accesses a later version, an error is returned:
E: Oracle> DBV file = E: oracleoradataytk102yangtk01. DBF blocksize = 8192
Dbverify: Release 9.2.0.4.0-production on Thursday March 26 21:42:06 2009
Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.
Dbverify-verification starting: file = E: oracleoradataytk102yangtk01. DBF import page 1-Possible Media corruption
***
Corrupt block relative DBA: 0x00000001 (File 0, Block 1)
Fractured block found during DBV:
Data in Bad block-
Type: 0 format: 0 rdba: 0x00000000
Last change SCN: 0x0000.00000000 seq: 0x0 flg: 0x00
Consistency value in tail: 0x00000010
Check value in block header: 0x0, block checksum disabled
Spare1: 0x0, spare2: 0x0, spare3: 0x0
***
Page 2 marked as corrupt
***
Corrupt block relative DBA: 0x00000002 (File 0, Block 2)
Bad header found during DBV:
Data in Bad block-
Type: 2 format: 0 rdba: 0x00000000
Last change SCN: 0x0000.00000000 seq: 0x0 flg: 0x00
Consistency value in tail: 0x00000000
Check value in block header: 0x0, block checksum disabled
Spare1: 0x0, spare2: 0x0, spare3: 0x0
***
.
.
. Imported page 16384-Possible Media damage
***
Corrupt block relative DBA: 0x00004000 (File 0, block 16384)
Fractured block found during DBV:
Data in Bad block-
Type: 0 format: 0 rdba: 0x00000000
Last change SCN: 0x0000.00000000 seq: 0x0 flg: 0x00
Consistency value in tail: 0x00000000
Check value in block header: 0x0, block checksum disabled
Spare1: 0x0, spare2: 0x0, spare3: 0x0
***
Dbverify-verification completed
Total number of checked pages: 16384 total number of processed pages (data): 0 total number of failed pages (data): 0 total number of processed pages (INDEX): 0 total number of failed pages (INDEX): 0 total number of pages processed (other): 0 total number of pages processed (segment): 0 total number of failed pages (segment): 0 total number of blank pages: 0 total number of pages marked as corrupted: 16384 total number of pages imported: 10744
The DBV tool is also used when the database is opened to verify the usage of the specified segment:
SQL> Conn/@ ytk92 as sysdba is connected.
SQL> select tablespace_id, header_file, header_block
2 from sys_dba_segs
3 where segment_name = 't_ T ';
Tablespace_id header_file header_block
------------------------------------
9 9 1387
In this method, you need to query the table space ID, the data file ID where the field header is located, and the tablespace ID where the field header is located. To obtain this information, you can query the sys_dba_segs view by using sys. Note that the sys_user_segs view provided in the Oracle document can only query the segments of SYS users. to query segment information of common users, you need to access sys_dba_segs.
E: Oracle> DBV userid = yangtk/yangtk segment_id = 9.9.1387
Dbverify: Release 9.2.0.4.0-production on Thursday March 26 21:56:19 2009
Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.
Dbverify-starting verification: segment_id = 9.9.1387
Dbverify-verification completed
Total number of checked pages: 512 total number of processed pages (data): 470 total number of failed pages (data): 0 total number of processed pages (INDEX): 26 total number of failed pages (INDEX): 0 total number of pages processed (other): 15 Total number of pages processed (segment): 1 Total number of failed pages (segment): 0 total number of blank pages: 0 marked as the total number of corrupted pages: 0 imported pages: 0
This method requires that the database is open.
Because DBV can verify the data file when the instance is closed, DBV can also verify the copy of the data file.
This copy refers to the data file copied through the Copy command of RMAN or the command CP of the operating system, rather than the backup set format generated by RMAN.
E: Oracle> RMAN target/
Recovery MANAGER: Version 9.2.0.4.0-Production
Copyright (c) 1995,200 2, Oracle Corporation. All rights reserved.
Connect to the target database: ytk92 (dbid = 1285986946)
RMAN> RUN
2> {
3> copy datafile 'e: oracleoradataytk92users01. dbf' to 'e: userbak. dbf ';
4>}
Start the channel (ora_disk_1 channel ora_disk_1: SID = 17 devtype = disk channel ora_disk_1: copied data file 9 output file name = E: userbak) allocated by copy from month 3 to 09. DBF recid = 1 Stamp = 682554612 complete copy in month-09
RMAN> exit
The recovery manager is complete.
E: Oracle> DBV file = E: userbak. DBF blocksize = 8192
Dbverify: Release 9.2.0.4.0-production on Thursday March 26 22:33:13 2009
Copyright (c) 1982,200 2, Oracle Corporation. All rights reserved.
Dbverify-verification starting: file = E: userbak. DBF
Dbverify-verification completed
Total number of checked pages: 8160 total number of processed pages (data): 7192 total number of failed pages (data): 0 total number of processed pages (INDEX): 415 total number of failed pages (INDEX): 0 total number of pages processed (other): 273 total number of pages processed (segment): 0 total number of failed pages (segment): 0 total number of blank pages: 280 total number of pages marked as corrupted: 0 total number of pages imported: 0