1. a
  2. b
  3. c
  4. d
  5. e
  6. f
  7. g
  8. h
  9. i
  10. j
  11. k
  12. l
  13. m
  14. n
  15. o
  16. p
  17. q
  18. r
  19. s
  20. t
  21. u
  22. v
  23. w
  24. x
  25. y
  26. z

View MySQL table structure from command line :

There are three ways to get MySQL table structure from command line. Using keyword DESCRIBE, selecting information from INFORMATION SCHEMA and SHOW FULL COLUMNS from table.

We have the table "countries" (created with the SQL below) and we want to check it's structure from command line.

CREATE TABLE `countries` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(64) DEFAULT NULL,
`url` varchar(64) DEFAULT NULL,
`status` int(11) DEFAULT '1',
`sell` int(11) DEFAULT '1' COMMENT '1 = enable selling, 0 = disable selling',
PRIMARY KEY (`id`),
UNIQUE KEY `name_UNIQUE` (`name`),
UNIQUE KEY `url_UNIQUE` (`url`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


Login to MySQL and select your database (You can include database name in the query if you want).

[root@comcmd /]# mysql -u mysql_user_name -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 666
Server version: 5.7.11 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use my_database_name;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>

From here you can use one of the following methods.

1) Using DESCRIBE

mysql> DESCRIBE countries;
+--------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(64) | YES | UNI | NULL | |
| url | varchar(64) | YES | UNI | NULL | |
| status | int(11) | YES | | 1 | |
| sell | int(11) | YES | | 1 | |
+--------+-------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
mysql>

2) Selecting information from INFORMATION SCHEMA. This way you can have a full description of the table.

mysql> SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'my_database_name' AND TABLE_NAME = 'countries';
3) With keywords SHOW FULL COLUMNS

mysql> SHOW FULL COLUMNS FROM `countries`;
This is the same as DESCRIBE but you will get also information about "Collation", "Privileges" and "Comments".