Oracle7 Server Distributed Systems Volume II: Replicated Data

Contents Index Home Previous Next

Determining Differences Between Replicated Tables

When administering a replicated environment, you may periodically want to check whether the contents of two replicated tables are identical. The following procedures in the DBMS_RECTIFIER_DIFF package let you identify, and optionally rectify, the differences between two tables when both sites are release 7.3 or higher:

DIFFERENCES The DIFFERENCES procedure compares two replicas of a table, and determines all rows in the first replica that are not in the second and all rows in the second that are not in the first. The output of this procedure is stored in two user-created tables. The first table stores the values of the missing rows, and the second table is used to indicate which site contains each row.
RECTIFY The RECTIFY procedure uses the information generated by the DIFFERENCES procedure to rectify the two tables. Any rows found in the first table and not in the second are inserted into the second table. Any rows found in the second table and not in the first are deleted from the second table.
To restore equivalency between all copies of a replicated table, you should complete the following steps:

    CREATE TABLE missing_rows_data
    (
       empno   NUMBER,
       sal     NUMBER,
       bonus   NUMBER
    )

    CREATE TABLE missing_rows_location
    (
       present   VARCHAR2(128),
       absent    VARCHAR2(128),
       r_id      ROWID
    )

    DBMS_RECTIFIER_DIFF.DIFFERENCES(
        sname1               =>  'hr',
        oname1               =>  'employee',
        reference_site       =>  'ny.com',
        sname2               =>  'hr',
        oname2               =>  'employee',
        comparison_site      =>  'sf.com',
        where_clause         =>  '',
        column_list          =>  'empno,sal,bonus',
        missing_rows_sname   =>  'scott',
        missing_rows_oname1  =>  'missing_rows_data',
        missing_rows_oname2  =>  'missing_rows_location',
        missing_rows_site    =>  'ny.com',
        max_missing          =>  100,
        commit_rows          =>  50);

Figure 7 - 1. Determining Differences Between Replicas

    DBMS_RECTIFIER_DIFF.RECTIFY(
        sname1               =>  'hr',
        oname1               =>  'employee',
        reference_site       =>  'ny.com',
        sname2               =>  'hr',
        oname2               =>  'employee',
        comparison_site      =>  'sf.com',
        column_list          =>  'empno,sal,bonus',
        missing_rows_sname   =>  'scott',
        missing_rows_oname1  =>  'missing_rows_data',
        missing_rows_oname2  =>  'missing_rows_location',
        missing_rows_site    =>  'ny.com',
        commit_rows          =>  50);

Attention: If you have any additional constraints on the "comparison" table you must ensure that they will not be violated when you call RECTIFY. You may need to update the table directly using the information from the missing rows table. If so, be certain to DELETE the appropriate rows from the missing rows tables.


Contents Index Home Previous Next