my $db1= first connection my $db2= second connection ... my $sth = $db1->prepare("SELECT constraint_name FROM information_schema.constraint_column_usage WHERE TABLE_NAME = '$tbl'"); $sth->execute; my $temp = $sth->fetchrow_arrayref; foreach my $rel (@$temp) { next unless ($rel =~ /ID/); print "Relationship: $rel\n"; my $th = $db2->prepare("ALTER TABLE Data_CentersTEST DROP CONSTRAINT $rel"); $th->execute; }