Syntax error Display information about field names in MySQL including TYPE, KEY, etc.

Display information about field names in MySQL including TYPE, KEY, etc.



To display information about field names, the syntax is as follows −

show columns from yourTableName;

Let us first create a table −

mysql> create table DemoTable1586
   -> (
   -> EmployeeId int,
   -> EmployeeFirstName varchar(20),
   -> EmployeeLastName varchar(20),
   -> EmployeeAge int,
   -> EmployeeCountryName varchar(20),
   -> EmployeeSalary int
   -> );
Query OK, 0 rows affected (0.78 sec)

Following is the query to display field names −

mysql> show columns from DemoTable1586;

This will produce the following output −

+---------------------+-------------+------+-----+---------+-------+
| Field               | Type        | Null | Key | Default | Extra |
+---------------------+-------------+------+-----+---------+-------+
| EmployeeId          | int(11)     |  YES |     | NULL    |       |
| EmployeeFirstName   | varchar(20) |  YES |     | NULL    |       |
| EmployeeLastName    | varchar(20) |  YES |     | NULL    |       |
| EmployeeAge         | int(11)     |  YES |     | NULL    |       |
| EmployeeCountryName | varchar(20) |  YES |     | NULL    |       |
| EmployeeSalary      | int(11)     |  YES |     | NULL    |       |
+---------------------+-------------+------+-----+---------+-------+
6 rows in set (0.11 sec)
Updated on: 2019-12-16T06:39:14+05:30

114 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements