To get the table column name from the database, we should use the following SQL query:
SHOW COLUMNS FROM table_name;
To get the values in perl we can use the following code:
my $sql_rep_x = 'SHOW COLUMNS FROM '.$table;
my $getkey_x = $dbh->prepare($sql_rep_x);
$getkey_x->execute;
while( my @row_x = $getkey_x->fetchrow_array ) {
push @names, $row_x[0];
}
$getkey_x->finish;