![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
Advertisements