

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
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)
- Related Questions & Answers
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How do I lag columns in MySQL?
- How do I clone the structure of a table in MySQL?
- How to list temporary table columns in MySQL?
- How do I alter a MySQL table column defaults?
- How do I get the creation date of a MySQL table?
- How do I detect if a table exist in MySQL?
- How do I view the auto_increment value for a table in MySQL?
- How do I show the schema of a table in a MySQL database?
- How do I list all files of a directory in Python?
- How do I remove all elements from a list in Java?
- How do I see all foreign keys to a table column?
- How do I remove a uniqueness constraint from a MySQL table?
- How do I show unique constraints of a table in MySQL?
- How do I get the current AUTO_INCREMENT value for a table in MySQL?
Advertisements