For future reference:
#!/usr/bin/perl
use DBI; use strict; my $user = ""; my $password = ""; my $database = "";
my $dbh = DBI->connect("dbi:mysql:$database","$user","$password") || die "Can't connect to DB:"; my $sth = $dbh->table_info; my @tables = @{$sth->fetchall_arrayref({})}; foreach my $table_info (@tables) { my $name = $table_info->{TABLE_NAME}; print $name,"\n"; $sth = $dbh->column_info(undef,$database,$name,'%'); my @info = @{$sth->fetchall_arrayref({})}; for my $field (@info) { print $field->{COLUMN_NAME}," = ",$field->{TYPE_NAME}, " : size ",$field->{COLUMN_SIZE},"\n"; } print "-"x100,"\n"; } $dbh->disconnect;
Re:Dumping DB schemas
Beatnik on 2006-07-10T06:49:28
Yes, I know.. but I did it for 2 reasons. 1) A friend asked me and I wanted to give him a quick respons that wouldn't include 'install this module'. 1) I never did any of that *_info stuff before so it was a good chance for me to dig into it:)