in reply to Re: DBI determine primary key
in thread DBI determine primary key

Actually, a different way using a different SQL query (which I was hoping to avoid, since that's dependent on parsing specific output):
my $keys_ref = $dbh->selectall_arrayref("SHOW KEYS FROM $table"); + foreach my $row ( @{$keys_ref} ) { print "Primary key: $row->[4]" if $row->[2] eq 'PRIMARY'; }
It'd probably be more readable to use a selectall_hashref and (in the MySQL case) snag
$row->{'Column_name'} if $row->{'Key_name'} eq 'PRIMARY'

Edited by Chady -- added code tags.