in reply to perl-mysql help - print table structure

Their is a variety of ways to achieve what you want. Remember anything you can do in SQL in the MySQL monitor can be done through the DBI. Do you use SHOW COLUMNS in the monitor? Well, why not use it in your programme?
sub getTableStructure { # need: $dbh # tablename # returns: hash of field(column) records my ($dbh, $tablename) = @_; my %struct_hash; my $SQL = "SHOW COLUMNS FROM $tablename"; my $sth = $dbh->prepare( $SQL ); $sth->execute(); while ( my $inphash = $sth->fetchrow_hashref() ) { . .whatever you need to do .}
Gives you the information about the table. You can take that info and then use it to build entire new tables! In my case I import a text file into a table where every field is of type VARCHAR and named 'fieldn'. Using this data form MySQL I map the input table fields to fields in the database, ALTER the table, add some fields and then append it to the destination table - all done using MySQL SQL statements via the DBI.

Go and try this sort of stuff out, and come back with more specific questions wehn you get stumped.

jdtoronto