- 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
How do I list all the 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
To Continue Learning Please Login
Login with Google