Вы можете сделать это в таблице information_schema.COLUMNS
.
SELECT
COLUMN_NAME,
TABLE_NAME,
CHARACTER_SET_NAME,
COLUMN_TYPE,
COLLATION_NAME
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = 'your_database_name'
Пример вывода из базы данных Gallery2:
+-------------------------+--------------------------+--------------------+--------------+-----------------+
| COLUMN_NAME | TABLE_NAME | CHARACTER_SET_NAME | COLUMN_TYPE | COLLATION_NAME |
+-------------------------+--------------------------+--------------------+--------------+-----------------+
| g_accessListId | g2_AccessMap | NULL | int(11) | NULL |
| g_userOrGroupId | g2_AccessMap | NULL | int(11) | NULL |
| g_permission | g2_AccessMap | NULL | int(11) | NULL |
| g_itemId | g2_AccessSubscriberMap | NULL | int(11) | NULL |
| g_accessListId | g2_AccessSubscriberMap | NULL | int(11) | NULL |
| g_id | g2_AlbumItem | NULL | int(11) | NULL |
| g_theme | g2_AlbumItem | utf8 | varchar(32) | utf8_general_ci |
| g_orderBy | g2_AlbumItem | utf8 | varchar(128) | utf8_general_ci |
| g_orderDirection | g2_AlbumItem | utf8 | varchar(32) | utf8_general_ci |