gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 23:50:35 25 4
gpt4 key购买 nike

我怎样才能从 mysql 表中获得 just 表注释?我尝试了以下方法,但由于各种原因它们没有工作。我想弄清楚如何只获取字符串“我的评论”(最好通过 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' |
+-------+------------------------------------------------------------------------------+

最佳答案

基于 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 |
+--------------------------+

关于mysql - 如何从 mysql 表访问表注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3938966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com