1SELECT COLUMN_NAME
2 FROM INFORMATION_SCHEMA.COLUMNS
3 WHERE TABLE_SCHEMA = 'my_database' AND TABLE_NAME = 'my_table';
4
1Copied mysql> DESCRIBE pet;
2+---------+-------------+------+-----+---------+-------+
3| Field | Type | Null | Key | Default | Extra |
4+---------+-------------+------+-----+---------+-------+
5| name | varchar(20) | YES | | NULL | |
6| owner | varchar(20) | YES | | NULL | |
7| species | varchar(20) | YES | | NULL | |
8| sex | char(1) | YES | | NULL | |
9| birth | date | YES | | NULL | |
10| death | date | YES | | NULL | |
11+---------+-------------+------+-----+---------+-------+