… my $sth = $dbh->prepare("show tables") or &bail($DBI::errstr); my $rv = $sth->execute or &bail($DBI::errstr); while ( ( my $table_name ) = $sth->fetchrow_array ) { $sth2 = $dbh->prepare("describe $table_name") or die print "Can't do select: $DBI::errstr"; $rv2 = $sth2->execute or die print "Can't execute the query: $DBI::errstr"; while (($field_, $type_, $null_,$key_, $default_, $extra_) = $sth2->fetchrow_array) { #stuff with cols and then rows. } } … #### … # Get a list of the tables my @table_names; eval { @table_names = @{$dbh->selectcol_arrayref("SHOW TABLES")}; 1; } or die "Couldn't retrieve list of MySQL tables: $DBI::errstr"; # Get data from each table my (@tables, $table); eval { foreach $table (@table_names) { # Record how the table is layed out my $layout = $dbh->selectall_arrayref("DESCRIBE $table"); # Store the data in a 2D array reference my @fields = map ${$_}[0], @{$layout}; my $data = $dbh->selectall_arrayref("SELECT " . (join ',', @fields) . " FROM $table"); push @tables, [$layout, $data]; } 1; } or die "Failed while obtaining data from $table: $DBI::errstr"; …