MySQLでテーブルのスキーマ(構造)を確認するコマンド

MySQLでは次のコマンドを実行するとテーブルスキーマ(カラムなどの構造)を確認できる。

SHOW COLUMNS FROM `users`;

実行結果は次のとおり。

SHOW COLUMNS FROM `users`;
+-----------------------+--------------+------+-----+---------+----------------+
| Field                 | Type         | Null | Key | Default | Extra          |
+-----------------------+--------------+------+-----+---------+----------------+
| id                    | int(11)      | NO   | PRI | NULL    | auto_increment |
| mail                  | varchar(255) | NO   |     | NULL    |                |
| tmp_mail              | varchar(255) | YES  |     | NULL    |                |
| nickname              | varchar(20)  | YES  |     | NULL    |                |
| password              | varchar(255) | YES  |     | NULL    |                |
| activate_hash         | mediumtext   | YES  |     | NULL    |                |
| activate_date         | datetime     | YES  |     | NULL    |                |
| payment               | tinyint(4)   | NO   |     | 2       |                |
| period                | mediumtext   | YES  |     | NULL    |                |
| webpay_customer_id    | mediumtext   | YES  |     | NULL    |                |
| webpay_recursion_id   | mediumtext   | YES  |     | NULL    |                |
| payjp_customer_id     | mediumtext   | YES  |     | NULL    |                |
| payjp_subscription_id | mediumtext   | YES  |     | NULL    |                |
| bank                  | mediumtext   | YES  |     | NULL    |                |
| branch                | mediumtext   | YES  |     | NULL    |                |
| bank_type             | tinyint(4)   | YES  |     | NULL    |                |
| bank_number           | int(11)      | YES  |     | NULL    |                |
| bank_meigi            | mediumtext   | YES  |     | NULL    |                |
| evernote_token        | mediumtext   | YES  |     | NULL    |                |
| evernote_expires      | datetime     | YES  |     | NULL    |                |
| type                  | mediumtext   | NO   |     | NULL    |                |
| created               | datetime     | NO   |     | NULL    |                |
| modified              | datetime     | NO   |     | NULL    |                |
+-----------------------+--------------+------+-----+---------+----------------+
comments powered by Disqus