Show Comment of Fields FROM Mysql Table
MysqlMysql Problem Overview
SHOW COLUMNS FROM <tablename>
gives all the information of the columns in a table, except Comments
.
How to extract Comments
information? I know the way to extract the information from INFORMATION SCHEMA, but how to combine the result in a single result set?
Mysql Solutions
Solution 1 - Mysql
You can use the query
SHOW FULL COLUMNS FROM <tablename>
If you don't want to use information_schema
.
Solution 2 - Mysql
select `column_name`, `column_type`, `column_default`, `column_comment`
from `information_schema`.`COLUMNS`
where `table_name` = 'table-name'
and `table_schema` = 'db-name';
Solution 3 - Mysql
In case you want to get the table comments instead :
SELECT table_comment
FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'my_table' and
table_schema = 'my_database'