DBMS_DBCOMP

The DBMS_DBCOMP package performs block comparison to detect lost writes or database inconsistencies between a primary database and one or more physical standby databases. It contains one procedure, DBCOMP, which can be executed at any time. (It does not require that the DB_LOST_WRITE_PROTECT initialization parameter be enabled.)

This chapter contains the following sections:

Related Topics

Using DBMS_DBCOMP

The DBMS_DBCOMP.DBCOMP procedure assumes that there is one primary database and one or more physical standby databases. The databases should be at least mounted before block comparison.

Note: Logical standby databases, far sync instances, and cascaded standbys cannot be the target database for the DBMS_DBCOMP.DBCOMP procedure.

While this procedure is running, you can monitor progress of the compare operation by querying the V$SESSION_LONGOPS view. For example:

SQL> SELECT target_desc, sofar, totalwork FROM V$SESSION_LONGOPS WHERE opname = 'BlockCompare';

The output might look as follows:

TARGET_DESC                   SO FAR     TOTALWORK
----------------------------- ---------  ----------
Compared Blocks               23914      340639
Lost Writes                   0          0

The results can be interpreted as follows:

DBMS_DBCOMP Security Model

The DBMS_DBCOMP package runs with invoker’s rights and requires the SYSDBA or SYSDG or SYSBACKUP privilege.

Summary of the DBMS_DBCOMP Subprogram

The DBMS_DBCOMP package contains one procedure, DBCOMP.

Subprogram Description
DBCOMP procedure The DBMS_DBCOMP.DBCOMP procedure performs block comparison to detect lost writes or database inconsistencies between a primary database and one or more physical standby databases. The DBCOMP procedure can be executed on the primary or on the physical standby while the databases are mounted or open.

DBCOMP Procedure

Use DBCOMP procedure to compare blocks on a primary database and one or more physical standby databases.

Syntax

DBMS_DBCOMP.DBCOMP (
  datafile IN varchar2,
  outputfile IN varchar2,
  block_dump IN boolean);

Parameters

Parameter Description
datafile This can be a data file name or a data file number. Specify 'ALL' to compare all data files.
outputfile This value is used as a prefix in the name of the output file. By default, output files are placed in the dbs/ directory, but the output file argument can contain a relative directory path or an absolute directory path. See Usage Notes for descriptions of the information contained in the output file.
block_dump This is a Boolean parameter to specify whether block content should be dumped into output files if a pair of blocks of primary and standby databases is not identical. This parameter does not guarantee that all different block pairs are dumped. The default value is FALSE.

Usage Notes

Example 69-1 Example

The following is an example of using the DBMS_DBCOMP.DBCOMP procedure.

declare
  Datafile_Name_or_Number varchar2(1000);
  Output_File varchar2(1000);
begin
  dbms_output.enable(1000000);
  Datafile_Name_or_Number:= 'all' ;
  Output_File:='BlockCompareAll_';
  sys.dbms_dbcomp.DBCOMP(Datafile_Name_or_Number, Output_File, true);
end;