MySQL 的 help 命令
mysql> help contents;
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
Account Management
Administration
Components
Compound Statements
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Storage Engines
Table Maintenance
Transactions
User-Defined Functions
Utility
help 语句信息从哪里取的
MySQL Server提供4张表用于保存服务端的帮助信息
help_category:关于帮助主题类别的信息
help_keyword:与帮助主题相关的关键字信息
help_relation:帮助关键字信息和主题信息之间的映射
help_topic:帮助主题的详细内容
mysql> show tables from mysql like 'help%';
+-------------------------+
| Tables_in_mysql (help%) |
+-------------------------+
| help_category |
| help_keyword |
| help_relation |
| help_topic |
+-------------------------+
4 rows in set (0.00 sec)
help 语句信息何时产生的
数据库初始化时通过加载MySQL/share/fill_help_tables.sql
文件创建
help 帮助信息存储表详解
mysql> desc mysql.help_category;
+--------------------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+----------------------+------+-----+---------+-------+
| help_category_id | smallint(5) unsigned | NO | PRI | NULL | |
| name | char(64) | NO | UNI | NULL | |
| parent_category_id | smallint(5) unsigned | YES | | NULL | |
| url | text | NO | | NULL | |
+--------------------+----------------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
mysql> desc mysql.help_topic;
+------------------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+----------------------+------+-----+---------+-------+
| help_topic_id | int(10) unsigned | NO | PRI | NULL | |
| name | char(64) | NO | UNI | NULL | |
| help_category_id | smallint(5) unsigned | NO | | NULL | |
| description | text | NO | | NULL | |
| example | text | NO | | NULL | |
| url | text | NO | | NULL | |
+------------------+----------------------+------+-----+---------+-------+
6 rows in set (0.00 sec)
mysql> desc mysql.help_keyword;
+-----------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+-------+
| help_keyword_id | int(10) unsigned | NO | PRI | NULL | |
| name | char(64) | NO | UNI | NULL | |
+-----------------+------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
mysql> desc mysql.help_relation;
+-----------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+------------------+------+-----+---------+-------+
| help_topic_id | int(10) unsigned | NO | PRI | NULL | |
| help_keyword_id | int(10) unsigned | NO | PRI | NULL | |
+-----------------+------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
help 查询原理
help 语句给定的关键字去匹配help_keyword表的name字段,如果有记录返回,则使用help_category、help_keyword、help_relation、help_topic四表做复杂的关联查询 ,没有记录放回 not found
help 语句注意点
HELP语句中给定的搜索关键字不区分大小写
搜索关键字可以包含通配符%和_,效果与LIKE运算符执行的模式匹配操作含义相同。例如:HELP ‘rep%’返回以rep开头的主题列表
如果帮助类别字符串、帮助主题字符串包含多个字符的,则可以使用引号引起来,也可以不使用引号,为避免歧义,最好使用引号引起来
一般软件都会带help帮助命令,MySQL也不例外,这个命令有助于开发者快熟上手软件,当然作为一个开发人员,主动了解help命令也是应该的,因为即使是解决问题的一群人也会有一时棘手的难题,这时候快速精准的寻求帮助就是一种宝贵的能力,这一点对于那些被不能快速找寻帮助而苦苦找寻文档资料的小伙伴们(如同我也是)应该深有体会