
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
List All Columns in a MySQL Table
To list all columns in a table, we can use the SHOW command. Let us first create a table.
mysql> create table ColumnsList -> ( -> id int, -> Firstname varchar(200), -> LastName varchar(100), -> Age int, -> Address varchar(300), -> CollegeName varchar(100) -> ); Query OK, 0 rows affected (1.33 sec)
Syntax to list all column names.
show columns from yourTableName;
The following is the output.
mysql> show columns from ColumnsList;
The following output displays all the column names.
+-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | Firstname | varchar(200) | YES | | NULL | | | LastName | varchar(100) | YES | | NULL | | | Age | int(11) | YES | | NULL | | | Address | varchar(300) | YES | | NULL | | | CollegeName | varchar(100) | YES | | NULL | | +-------------+--------------+------+-----+---------+-------+ 6 rows in set (0.00 sec)
Advertisements