#!/usr/bin/perl # Compare two schemas or tables for names, types and length. use v5.10; no strict; my %DS1=( PERL => [ {TABLES=>{ TABSCHEMA=>"VARCHAR(128)", TABNAME=>"VARCHAR(128)", }}, # Tables and Columns are names of the tables. {COLUMNS=>{ TABSCHEMA=>"VARCHAR(128)", TABNAME=>"VARCHAR(128)", COLNAME=>"VARCHAR(128)", PARTKEYSEQ=>"SMALLINT", }} ] ); my %DS2=( PERL => [ {TABLES=>{ TABSCHEMA=>"VARCHAR(256)", TABNAME=>"VARCHAR(128)", }}, # Tables and Columns are names of the tables. {COLUMNS=>{ TABSCHEMA=>"VARCHAR(256)", TABNAME=>"VARCHAR(128)", COLNAME=>"VARCHAR(128)", PARTKEYSEQ=>"SMALLINT", }} ] ); foreach my $schema1 (keys %DS1) { if (exists $DS2{$schema1}) { say "Schema $schema1 exist in target."; foreach my $tables1_ref (@{$DS1{$schema1}}) { foreach my $tables2_ref (@{$DS2{$schema1}}) { foreach my $tabnames1 (keys %{$tables1_ref}) { if (exists $tables2_ref->{$tabnames1}) { say "$tabnames1 exists in target schema DS2"; } else { say "$tabnames1 does not exist in target schema DS2"; } say "\n" } } } } else { say "Schema $schema1 does not exist in target."; } }