1 2
my $stmt = "SELECT schema_name FROM information_schema.schemata ORDER BY schema_name"; my $databases = $dbh->selectcol_arrayref( $stmt, {}, () );
1 2
my $stmt = "SELECT table_name FROM information_schema.tables WHERE table_schema = ? ORDER BY table_name"; my $tables = $dbh->selectcol_arrayref( $stmt, {}, ( $schema ) );
1 2 3
my $sth = $dbh->prepare( "SELECT * FROM $table LIMIT 0" ); $sth->execute(); my $columns = $sth->{NAME};
1 2 3 4 5 6 7 8 9 10 11 12 13
my $stmt = "SELECT table_name FROM information_schema.tables WHERE table_schema = ? ORDER BY table_name"; my $tables = $dbh->selectcol_arrayref( $stmt, {}, ( $schema ) ); my $my_table = $tables->[0]; my $sth = $dbh->prepare( "SELECT * FROM $my_table LIMIT 0" ); $sth->execute(); my $columns = $sth->{NAME}; my $col_1 = shift @$columns; my $sth = $dbh->prepare( "SELECT $col_1 FROM $my_table" ); $sth->execute(); $sth->dump_results;