Bootstrap FreeKB - mySQL / MariaDB - List the columns in a table using the show columns or describe command
mySQL / MariaDB - List the columns in a table using the show columns or describe command

Updated:   |  mySQL / MariaDB articles

The show columns or describe <tablename> commands can be used to list the columns in a table. You will first need to log into your MariaDB or mySQL server or configure passwordless authentication and then use the -e command line option.

In this example, the columns in table001 in the database named db001 will be listed.

use db001; describe table001;

 

Or like this.

describe db001.table001;

 

Something like this should be returned.

+-----------------+---------------+------+-----+---------+----------------+
| Field           | Type          | Null | Key | Default | Extra          |
+-----------------+---------------+------+-----+---------+----------------+
| id              | int(11)       | NO   | PRI | NULL    | auto_increment |
| column001       | varchar(200)  | NO   |     | NULL    |                |
| column002       | varchar(1000) | NO   |     | NULL    |                |
| column003       | varchar(2000) | NO   |     | NULL    |                |
+-----------------+---------------+------+-----+---------+----------------+

 

 

Something like this should be returned.

+-----------------+---------------+------+-----+---------+----------------+
| Field           | Type          | Null | Key | Default | Extra          |
+-----------------+---------------+------+-----+---------+----------------+
| id              | int(11)       | NO   | PRI | NULL    | auto_increment |
| foo             | varchar(250)  | NO   |     | NULL    |                |
| column002       | varchar(1000) | NO   |     | NULL    |                |
| column003       | varchar(2000) | NO   |     | NULL    |                |
+-----------------+---------------+------+-----+---------+----------------+

 

Or, the show columns command can be used.

show columns from db001.table001;

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 1d7e98 in the box below so that we can be sure you are a human.