11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 3 ■ DATABASE ADMINISTRATION 145Now that we made sure the emp table in the two databases diverges, it’s time to run thecreate_comparison procedure to trap the data divergence between the two tables.3. Create a comparison for the hr.emp table on the two databases by running thecreate_comparison procedure, as shown here:SQL> begin2 dbms_comparison.create_comparison(3 comparison_name => 'compare1',4 schema_name => 'scott',5 object_name => 'emp',6 dblink_name => 'tenner');7* end;SQL> /PL/SQL procedure successfully completed.SQL>4. Execute the compare function to see whether the create_comparison procedure hasfound any differences between the two tables.SQL> declare2 consistent boolean;3 scan_info dbms_comparison.comparison_type;4 begin5 consistent := dbms_comparison.compare(6 comparison_name => 'comp1',7 scan_info => scan_info,8 perform_row_dif => TRUE);9 DBMS_OUTPUT.PUT_LINE('Scan ID: '||scan_info.scan_id);10 IF consistent=TRUE THEN<strong>11</strong> DBMS_OUTPUT.PUT_LINE('No differences were found.');12 ELSE13 DBMS_OUTPUT.PUT_LINE('Differences were found.');14 end if;15* end;SQL> /Scan ID: 4Differences were found.PL/SQL procedure successfully completed.SQL>5. The compare function uses the scan ID 4 and prints the statement “Differences were found.”6. Since there are differences, you can run the following query, which uses the viewsDBA_COMPARISON and DBA_COMPARISON_SCAN_SUMMARY to tell us how many differences werefound during the table comparison:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!