#1. SQL .txt contains multiple SQL statements: Select * From Testa select * From testb select * From testcselect * From testd select * From teste select * From testf #2. the Perl script is as follows. The execution results will be placed in the CSV file corresponding to the table using strict; Use warnings; Use dBi; Main (); sub main {my $ dbh_oracle; my $ dbh_mysql; open (in, "SQL .txt") or die "$ !, Opening SQL .txt \ n "; open (fail,"> 00fail.csv ") or die 'unable to create diff file for 00fail.csv $! '; While (<in>) {chomp; # Oracle $ dbh_oracle = DBI-> connect ("DBI: oracle: host = xxx. XX. XX. xxx; SERVICE_NAME = xxx; ", 'xxx', 'xxx') | die" cannot connect to Oracle: $! \ N "; my @ Oracle = getresult ($ dbh_oracle, $ _); # MySQL $ dbh_mysql = DBI-> connect ('dbi: mysql: Database = xxxx; host = xxx. XX. XX. XXX', 'xxx', 'xxx') | die "cannot connect to MySQL: $! \ N "; my @ MySQL = getresult ($ dbh_mysql, $ _); # sqlserver # my $ dbh_sqlservr = DBI-> connect (" DBI: Ado: driver = {SQL Server}; server = localhost; database = xxxx; ", 'xxx', 'xxx') | die" cannot connect to MySQL: $! \ N "; # My @ sqlserver = getresult ($ dbh_sqlservr, $ _); my @ output = Split //; my $ outputname = $ output [-1]; compare (\ @ Oracle, \ @ MySQL, $ outputname);} $ dbh_oracle-> disconnect (); $ dbh_mysql-> disconnect (); close in; close fail ;} sub getresult {my $ DBH = shift; my $ SQL = shift; my @ A; my $ something = $ DBH-> prepare ($ SQL); $ th-> execute; my $ numfields = $ something-> {'num _ of_fields '}; while (my $ ref = $ something-> fetchrow_ar Rayref) {my $ line = ""; for (my $ I = 0; $ I <$ numfields; $ I ++) {$ line. = $ Ref [$ I] If (defined $ Ref [$ I]); $ line. = "," ;}# print out "\ n"; push @ A, $ line ;}$ something-> finish; return @ ;} sub compare {My ($ a_ref, $ B _ref, $ outname) = @ _; my % ta; my @ onlya; my @ onlyb; my @ same; foreach (@ $ a_ref) {chomp; $ Ta {$ _} + = 1;} My % COUNT = % ta; foreach (@ $ B _ref) {chomp; if (exists ($ Ta {$ _}) & $ Ta {$ _}> 0) {$ Ta {$ _}-= 1;} else {push @ onlyb, $ _ ;}} my $ counta; foreach (Keys % Ta) {my $ TMP = $ _; if ($ Ta {$ _}> = 0) {# Only A for (1 .. $ Ta {$ _}) {push @ onlya, $ TMP ;}# same for (1 .. ($ count {$ _}-$ Ta {$ _}) {push @ same, $ TMP ;}}} if ($ # onlyb> 0 or $ # onlya> 0) {print fail "$ outname \ n" if ($ # onlyb> 0 or $ # onlya> 0 ); open (Out, "> export outname.csv") or die 'unable to create diff file for export outname.csv $! '; Print out "only in Oracle: \ n"; print out $ _. "\ n" foreach @ onlya; print out "only in MySQL: \ n"; print out $ _. "\ n" foreach @ onlyb; print out "same: \ n"; print out $ _. "\ n" foreach @ same; close out ;}}