use strict; use DBI; my ($results, $subresults, $subresults1, $ref,$ref1,$ref2,$subref,$subref1) = undef; my @queries; my $dbh = DBI->connect("DBI:mysql:;host=127.0.0.1:3306",'root','fbg4ips') or die $DBI::errstr; $results = $dbh->prepare("show databases;") or die $dbh->errstr(); $results->execute() or die $results->errstr(); my $count = 1; while ($ref = $results->fetchrow_hashref()) { my $db = $ref->{'Database'}; print $db; print "\n"; $subresults = $dbh->prepare("show tables from $ref->{'Database'};") or die $dbh->errstr(); $subresults->execute() or die $subresults->errstr(); while ($subref = $subresults->fetchrow_hashref()) { my $table_name = $subref->{'Tables_in_'.$ref->{'Database'}}; print "--> "; print $table_name; $subresults1 = $dbh->prepare("show create table $db.$table_name;") or die $dbh->errstr(); $subresults1->execute() or die $subresults1->errstr(); $subref1 = $subresults1->fetchrow_hashref(); my $create_table = $subref1->{'Create Table'}; $create_table =~ /ENGINE=(\w+)/; my $type = $1; print " Type $type"; if ($type =~ /maria/i and $db !~ /mysql/i and $db !~ /information_schema/) { push @queries, "alter table $db.$table_name ENGINE=MyISAM;" } print "\n"; } } foreach (@queries) { $results = $dbh->prepare($_) or die $dbh->errstr(); $results->execute() or die $results->errstr(); print "Executed -> $_\n"; }