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

MySQLMySQLi Database

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.

raja
Published on 19-Feb-2018 08:06:47
Advertisements