如何从mysql表中访问表注释?

时间:2010-10-15 02:04:29

标签: mysql comments

如何从mysql表中获取只是表注释?我尝试了以下方法,但由于各种原因它们无法正常工作。我想弄清楚如何获得字符串'我的评论'(理想情况下通过perl =)

任何帮助?

-- Abbreviated output for convenience.
SHOW TABLE STATUS WHERE Name="foo"
+------+--------+---------+------------+------+----------------+---------------+
| Name | Engine | Version | Row_format | Rows | Create_options | Comment       |
+------+--------+---------+------------+------+----------------+---------------+
| foo  | MyISAM |      10 | Fixed      |    0 |                | my comment    | 
+------+--------+---------+------------+------+----------------+---------------+

SHOW CREATE TABLE foo;
+-------+------------------------------------------------------------------------------+
| Table | Create Table                                                                 |
+-------+------------------------------------------------------------------------------+
| fooo  | CREATE TABLE `fooo` (`id` int(11) NOT NULL PRIMARY KEY) COMMENT='my comment' | 
+-------+------------------------------------------------------------------------------+

2 个答案:

答案 0 :(得分:34)

根据 OMG Ponies 的回答,但使用INFORMATION_SCHEMA.TABLES代替INFORMATION_SCHEMA.COLUMNS。在网上浏览时,我所能找到的只是列的评论信息,但从不在桌面上。这是如何获取表的评论。

SELECT table_comment 
    FROM INFORMATION_SCHEMA.TABLES 
    WHERE table_schema='my_cool_database' 
        AND table_name='user_skill';

+--------------------------+
| table_comment            |
+--------------------------+
| my awesome comment       | 
+--------------------------+

答案 1 :(得分:1)

如果您不想在查询中同时拥有数据库名称和表名,则可以使用:

Dim Data() as Double
Redim Data(1 to YearAmount,1 to 12,1 to 31,0 to 23) as Double

然后拿起"评论"结果的关键(你必须在php中使用像mysqli_fetch_assoc()这样的关联命令。)