Love澤's Room

技術系ネタをまとめていたブログ。現在はカテゴリにこだわらず更新中。

MariaDB(MySQL)でカラムコメントを追加・確認する方法

新サイトへ移転しました
約3秒後に自動的にリダイレクトします。


テーブル追加時に以下のようにコメントを書くことができる。

MariaDB [test_db]> create table test_table (
    -> id int not null primary key auto_increment,
    -> name varchar(20) not null,
    -> birthday date comment '誕生日'
    -> );
Query OK, 0 rows affected (0.20 sec)

このとき、comment文で書いたコメントを確認する場合、以下の方法で確認することが出来る。

MariaDB [test_db]> show full columns from test_table;
+----------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+-----------+
| Field    | Type        | Collation       | Null | Key | Default | Extra          | Privileges                      | Comment   |
+----------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+-----------+
| id       | int(11)     | NULL            | NO   | PRI | NULL    | auto_increment | select,insert,update,references |           |
| name     | varchar(20) | utf8_general_ci | NO   |     | NULL    |                | select,insert,update,references |           |
| birthday | date        | NULL            | YES  |     | NULL    |                | select,insert,update,references | 誕生日    |
+----------+-------------+-----------------+------+-----+---------+----------------+---------------------------------+-----------+
3 rows in set (0.00 sec)