#!/usr/bin/perl -w use strict; use DBI; use DBD::Oracle; my $db1 = DBI->connect("dbi:Oracle:server=XXXX;database=XXXX", "USER","PASSWD") or die "Failed to connect to the database!"; my $db2 = DBI->connect("dbi:Oracle:server=XXXX;database=XXXX", "USER","PASSWD") or die "Failed to connect to the database!"; my $table = "DUMMY"; # name of the table my $unique_id = "ID"; # unique id to identify the row my $sth1 = $db1->prepare( "select * from $table" ); my $sth2 = $db2->prepare( "select * from $table where $unique_id=?" ); $sth1->execute(); while (my $row = $sth1->fetchrow_hashref()) { my $found = 0; $sth2->execute( $row->{$unique_id} ); while (my $row2 = $sth2->fetchrow_hashref()) { # compare the row foreach (keys %$row) { if ($row{$_} ne $row2{$_}) { print "DIFF: (ID) $_\n"; break; } } } } $sth->finish; $dbh->disconnect;