// Replace 'your_table_name' with the name of the table you want to retrieve the structure for.
global $wpdb;
$table_name = $wpdb->prefix . 'your_table_name';
$table_structure = $wpdb->get_results("DESCRIBE $table_name");
if ($table_structure) {
echo '<pre>';
echo "Table Structure for $table_name:\n\n";
foreach ($table_structure as $column) {
echo "Field: {$column->Field}\n";
echo "Type: {$column->Type}\n";
echo "------------------------\n";
}
echo '</pre>';
} else {
echo "Table $table_name not found or empty.";
}
#database #table