
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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 Articles
- 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 to list temporary table columns in MySQL?
- How do I clone the structure of a table in MySQL?
- How do I detect if a table exist in MySQL?
- How do I alter a MySQL table column defaults?
- How do I view the auto_increment value for a table in MySQL?
- How can we get a list of columns in an existing MySQL table?
- How do I list all files of a directory in Python?
- How do I get the creation date of a MySQL table?
- How do I show the schema of a table in a MySQL database?
- How do I SELECT none of the rows and columns in MySQL?
- How do I show unique constraints of a table in MySQL?
- How do I add a check constraint to a table in MySQL?
- How do I see all foreign keys to a table column?

Advertisements