How can we get a list of columns in an existing MySQL table?

MySQLMySQLi Database

MySQL Database Training for Beginners

39 Lectures 5.5 hours

Python programming with MySQL database: from Scratch

152 Lectures 16 hours

Learn MySQL from scratch for Data Science and Analytics

87 Lectures 5.5 hours

Suppose if we forgot the names of the columns in an existing table then we can use SHOW COLUMNS statement as follows to get the list of columns −

mysql> SHOW COLUMNS from Employee\G

*************************** 1. row ***************************
Field: Id
Type: int(11)
Null: YES
Key:
Default: NULL
Extra:
*************************** 2. row ***************************
Field: Name
Type: varchar(20)
Null: YES
Key:
Default: NULL
Extra:

2 rows in set (0.07 sec)

In the example above, we got the list of columns of ‘Employee’ table with the help of SHOW COLUMNS statement.

Updated on 29-Jan-2020 05:14:17