高效查看MySQL帮助文档的方法 (转)

在mysql的使用过程中, 可能经常会遇到以下问题:文章来源地址https://www.yii666.com/article/332700.html文章地址https://www.yii666.com/article/332700.html网址:yii666.com

  • 某个操作语法忘记了, 如何快速查找?
  • 如何快速知道当前版本上某个字段类型的取值范围?
  • 当前版本都支持哪些函数?希望有例子说明..
  • 当前版本是否支持某个功能?
    对于上面列出的问题, 我们可能想到的方法是查找MySQL的文档, 这些问题在官方文档都可以很清楚地查到, 但是却要耗费大量的时间和精力.
    所以对于以上问题, 最好的解决办法就是使用MySQL安装后自带的帮助文档, 这样在遇到问题时就可以方便快捷地进行查询.
 
 

按层次查看帮助

查看目录

如果不知道帮助能够提供些什么, 可以用"? contents"命令来显示所有可供查询的分类, 如下例所示:
  1. mysql> ? contents
  2. You asked for help about help category: "Contents"
  3. For more information, type 'help <item>', where <item> is one of the following
  4. categories:
  5. Account Management
  6. Administration
  7. Compound Statements
  8. Data Definition
  9. Data Manipulation
  10. Data Types
  11. Functions
  12. Functions and Modifiers for Use with GROUP BY
  13. Geographic Features
  14. Help Metadata
  15. Language Structure
  16. Plugins
  17. Procedures
  18. Storage Engines
  19. Table Maintenance
  20. Transactions
  21. User-Defined Functions
  22. Utility
mysql> ? 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
Compound Statements
Data Definition
Data Manipulation
Data Types
Functions
Functions and Modifiers for Use with GROUP BY
Geographic Features
Help Metadata
Language Structure
Plugins
Procedures
Storage Engines
Table Maintenance
Transactions
User-Defined Functions
Utility

查看数据类型

对于列出的分类, 可以使用"? 类别名称"的方式针对用户感兴趣的内容做进一步的查看, 例如, 想看看MySQL都支持哪些数据类型, 可以执行"? data tyeps"命令:
  1. mysql> ? data types
  2. You asked for help about help category: "Data Types"
  3. For more information, type 'help <item>', where <item> is one of the following
  4. topics:
  5. AUTO_INCREMENT
  6. BIGINT
  7. BINARY
  8. BIT
  9. BLOB
  10. BLOB DATA TYPE
  11. BOOLEAN
  12. CHAR
  13. CHAR BYTE
  14. DATE
  15. DATETIME
  16. DEC
  17. DECIMAL
  18. DOUBLE
  19. DOUBLE PRECISION
  20. ENUM
  21. FLOAT
  22. INT
  23. INTEGER
  24. LONGBLOB
  25. LONGTEXT
  26. MEDIUMBLOB
  27. MEDIUMINT
  28. MEDIUMTEXT
  29. SET DATA TYPE
  30. SMALLINT
  31. TEXT
  32. TIME
  33. TIMESTAMP
  34. TINYBLOB
  35. TINYINT
  36. TINYTEXT
  37. VARBINARY
  38. VARCHAR
  39. YEAR DATA TYPE
mysql> ? data types
You asked for help about help category: "Data Types"
For more information, type 'help <item>', where <item> is one of the following
topics:
AUTO_INCREMENT
BIGINT
BINARY
BIT
BLOB
BLOB DATA TYPE
BOOLEAN
CHAR
CHAR BYTE
DATE
DATETIME
DEC
DECIMAL
DOUBLE
DOUBLE PRECISION
ENUM
FLOAT
INT
INTEGER
LONGBLOB
LONGTEXT
MEDIUMBLOB
MEDIUMINT
MEDIUMTEXT
SET DATA TYPE
SMALLINT
TEXT
TIME
TIMESTAMP
TINYBLOB
TINYINT
TINYTEXT
VARBINARY
VARCHAR
YEAR DATA TYPE
上面列出了此版本支持的所有数据类型, 如果想知道int类型的具体介绍, 也可以利用上面的方法, 做进一步的查看:
  1. mysql> ? int
  2. Name: 'INT'
  3. Description:
  4. INT[(M)] [UNSIGNED] [ZEROFILL]
  5. A normal-size integer. The signed range is -2147483648 to 2147483647.
  6. The unsigned range is 0 to 4294967295.
  7. URL: http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html
mysql> ? int
Name: 'INT'
Description:
INT[(M)] [UNSIGNED] [ZEROFILL]
A normal-size integer. The signed range is -2147483648 to 2147483647.
The unsigned range is 0 to 4294967295.
URL: http://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html

查看函数

  1. mysql> ? functions
  2. You asked for help about help category: "Functions"
  3. For more information, type 'help <item>', where <item> is one of the following
  4. categories:
  5. Bit Functions
  6. Comparison operators
  7. Control flow functions
  8. Date and Time Functions
  9. Encryption Functions
  10. Information Functions
  11. Logical operators
  12. Miscellaneous Functions
  13. Numeric Functions
  14. String Functions
mysql> ? functions
You asked for help about help category: "Functions"
For more information, type 'help <item>', where <item> is one of the following
categories:
Bit Functions
Comparison operators
Control flow functions
Date and Time Functions
Encryption Functions
Information Functions
Logical operators
Miscellaneous Functions
Numeric Functions
String Functions
再根据列出的目录查看相应函数,比如查看都有什么日期函数
  1. mysql> ? Date and Time Functions
  2. You asked for help about help category: "Date and Time Functions"
  3. For more information, type 'help <item>', where <item> is one of the following
  4. topics:
  5. ADDDATE
  6. ADDTIME
  7. CONVERT_TZ
  8. CURDATE
  9. CURRENT_DATE
  10. CURRENT_TIME
  11. CURRENT_TIMESTAMP
  12. CURTIME
  13. DATE FUNCTION
  14. DATEDIFF
  15. DATE_ADD
  16. DATE_FORMAT
  17. DATE_SUB
  18. DAY
  19. DAYNAME
  20. DAYOFMONTH
  21. DAYOFWEEK
  22. DAYOFYEAR
  23. EXTRACT
  24. FROM_DAYS
  25. FROM_UNIXTIME
  26. GET_FORMAT
  27. HOUR
  28. LAST_DAY
  29. LOCALTIME
  30. LOCALTIMESTAMP
  31. MAKEDATE
  32. MAKETIME
  33. MICROSECOND
  34. MINUTE
  35. MONTH
  36. MONTHNAME
  37. NOW
  38. PERIOD_ADD
  39. PERIOD_DIFF
  40. QUARTER
  41. SECOND
  42. SEC_TO_TIME
  43. STR_TO_DATE
  44. SUBDATE
  45. SUBTIME
  46. SYSDATE
  47. TIME FUNCTION
  48. TIMEDIFF
  49. TIMESTAMP FUNCTION
  50. TIMESTAMPADD
  51. TIMESTAMPDIFF
  52. TIME_FORMAT
  53. TIME_TO_SEC
  54. TO_DAYS
  55. TO_SECONDS
  56. UNIX_TIMESTAMP
  57. UTC_DATE
  58. UTC_TIME
  59. UTC_TIMESTAMP
  60. WEEK
  61. WEEKDAY
  62. WEEKOFYEAR
  63. YEAR
  64. YEARWEEK
mysql> ? Date and Time Functions
You asked for help about help category: "Date and Time Functions"
For more information, type 'help <item>', where <item> is one of the following
topics:
ADDDATE
ADDTIME
CONVERT_TZ
CURDATE
CURRENT_DATE
CURRENT_TIME
CURRENT_TIMESTAMP
CURTIME
DATE FUNCTION
DATEDIFF
DATE_ADD
DATE_FORMAT
DATE_SUB
DAY
DAYNAME
DAYOFMONTH
DAYOFWEEK
DAYOFYEAR
EXTRACT
FROM_DAYS
FROM_UNIXTIME
GET_FORMAT
HOUR
LAST_DAY
LOCALTIME
LOCALTIMESTAMP
MAKEDATE
MAKETIME
MICROSECOND
MINUTE
MONTH
MONTHNAME
NOW
PERIOD_ADD
PERIOD_DIFF
QUARTER
SECOND
SEC_TO_TIME
STR_TO_DATE
SUBDATE
SUBTIME
SYSDATE
TIME FUNCTION
TIMEDIFF
TIMESTAMP FUNCTION
TIMESTAMPADD
TIMESTAMPDIFF
TIME_FORMAT
TIME_TO_SEC
TO_DAYS
TO_SECONDS
UNIX_TIMESTAMP
UTC_DATE
UTC_TIME
UTC_TIMESTAMP
WEEK
WEEKDAY
WEEKOFYEAR
YEAR
YEARWEEK

快速查阅帮助

    在实际应用当中, 如果需要快速查阅某项语法时, 可以使用关键字进行快速查询. 例如, 想知道show命令都能看到什么东西, 可以用如下命令:
  1. mysql> ? show
  2. Name: 'SHOW'
  3. Description:
  4. SHOW has many forms that provide information about databases, tables,
  5. columns, or status information about the server. This section describes
  6. those following:
  7. SHOW AUTHORS
  8. SHOW {BINARY | MASTER} LOGS
  9. SHOW BINLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
  10. SHOW CHARACTER SET [like_or_where]
  11. SHOW COLLATION [like_or_where]
  12. SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [like_or_where]
  13. SHOW CONTRIBUTORS
  14. SHOW CREATE DATABASE db_name
  15. SHOW CREATE EVENT event_name
  16. SHOW CREATE FUNCTION func_name
  17. SHOW CREATE PROCEDURE proc_name
  18. SHOW CREATE TABLE tbl_name
  19. SHOW CREATE TRIGGER trigger_name
  20. SHOW CREATE VIEW view_name
  21. SHOW DATABASES [like_or_where]
  22. SHOW ENGINE engine_name {STATUS | MUTEX}
  23. SHOW [STORAGE] ENGINES
  24. SHOW ERRORS [LIMIT [offset,] row_count]
  25. SHOW EVENTS
  26. SHOW FUNCTION CODE func_name
  27. SHOW FUNCTION STATUS [like_or_where]
  28. SHOW GRANTS FOR user
  29. SHOW INDEX FROM tbl_name [FROM db_name]
  30. SHOW MASTER STATUS
  31. SHOW OPEN TABLES [FROM db_name] [like_or_where]
  32. SHOW PLUGINS
  33. SHOW PROCEDURE CODE proc_name
  34. SHOW PROCEDURE STATUS [like_or_where]
  35. SHOW PRIVILEGES
  36. SHOW [FULL] PROCESSLIST
  37. SHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n]
  38. SHOW PROFILES
  39. SHOW SLAVE HOSTS
  40. SHOW SLAVE STATUS
  41. SHOW [GLOBAL | SESSION] STATUS [like_or_where]
  42. SHOW TABLE STATUS [FROM db_name] [like_or_where]
  43. SHOW [FULL] TABLES [FROM db_name] [like_or_where]
  44. SHOW TRIGGERS [FROM db_name] [like_or_where]
  45. SHOW [GLOBAL | SESSION] VARIABLES [like_or_where]
  46. SHOW WARNINGS [LIMIT [offset,] row_count]
  47. like_or_where:
  48. LIKE 'pattern'
  49. | WHERE expr
  50. If the syntax for a given SHOW statement includes a LIKE 'pattern'
  51. part, 'pattern' is a string that can contain the SQL "%" and "_"
  52. wildcard characters. The pattern is useful for restricting statement
  53. output to matching values.
  54. Several SHOW statements also accept a WHERE clause that provides more
  55. flexibility in specifying which rows to display. See
  56. http://dev.mysql.com/doc/refman/5.5/en/extended-show.html.
  57. URL: http://dev.mysql.com/doc/refman/5.5/en/show.html
mysql> ? show
Name: 'SHOW'
Description:
SHOW has many forms that provide information about databases, tables,
columns, or status information about the server. This section describes
those following:
SHOW AUTHORS
SHOW {BINARY | MASTER} LOGS
SHOW BINLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
SHOW CHARACTER SET [like_or_where]
SHOW COLLATION [like_or_where]
SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [like_or_where]
SHOW CONTRIBUTORS
SHOW CREATE DATABASE db_name
SHOW CREATE EVENT event_name
SHOW CREATE FUNCTION func_name
SHOW CREATE PROCEDURE proc_name
SHOW CREATE TABLE tbl_name
SHOW CREATE TRIGGER trigger_name
SHOW CREATE VIEW view_name
SHOW DATABASES [like_or_where]
SHOW ENGINE engine_name {STATUS | MUTEX}
SHOW [STORAGE] ENGINES
SHOW ERRORS [LIMIT [offset,] row_count]
SHOW EVENTS
SHOW FUNCTION CODE func_name
SHOW FUNCTION STATUS [like_or_where]
SHOW GRANTS FOR user
SHOW INDEX FROM tbl_name [FROM db_name]
SHOW MASTER STATUS
SHOW OPEN TABLES [FROM db_name] [like_or_where]
SHOW PLUGINS
SHOW PROCEDURE CODE proc_name
SHOW PROCEDURE STATUS [like_or_where]
SHOW PRIVILEGES
SHOW [FULL] PROCESSLIST
SHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n]
SHOW PROFILES
SHOW SLAVE HOSTS
SHOW SLAVE STATUS
SHOW [GLOBAL | SESSION] STATUS [like_or_where]
SHOW TABLE STATUS [FROM db_name] [like_or_where]
SHOW [FULL] TABLES [FROM db_name] [like_or_where]
SHOW TRIGGERS [FROM db_name] [like_or_where]
SHOW [GLOBAL | SESSION] VARIABLES [like_or_where]
SHOW WARNINGS [LIMIT [offset,] row_count]
like_or_where:
LIKE 'pattern'
| WHERE expr
If the syntax for a given SHOW statement includes a LIKE 'pattern'
part, 'pattern' is a string that can contain the SQL "%" and "_"
wildcard characters. The pattern is useful for restricting statement
output to matching values.
Several SHOW statements also accept a WHERE clause that provides more
flexibility in specifying which rows to display. See
http://dev.mysql.com/doc/refman/5.5/en/extended-show.html.
URL: http://dev.mysql.com/doc/refman/5.5/en/show.html
例如, 想查看某个函数CONCAT的使用
  1. mysql> ? concat
  2. Name: 'CONCAT'
  3. Description:
  4. Syntax:
  5. CONCAT(str1,str2,...)
  6. Returns the string that results from concatenating the arguments. May
  7. have one or more arguments. If all arguments are nonbinary strings, the
  8. result is a nonbinary string. If the arguments include any binary
  9. strings, the result is a binary string. A numeric argument is converted
  10. to its equivalent string form. This is a nonbinary string as of MySQL
  11. 5.5.3. Before 5.5.3, it is a binary string; to to avoid that and
  12. produce a nonbinary string, you can use an explicit type cast, as in
  13. this example:
  14. SELECT CONCAT(CAST(int_col AS CHAR), char_col);
  15. CONCAT() returns NULL if any argument is NULL.
  16. URL: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html
  17. Examples:
  18. mysql> SELECT CONCAT('My', 'S', 'QL');
  19. -> 'MySQL'
  20. mysql> SELECT CONCAT('My', NULL, 'QL');
  21. -> NULL
  22. mysql> SELECT CONCAT(14.3);
  23. -> '14.3'
mysql> ? concat
Name: 'CONCAT'
Description:
Syntax:
CONCAT(str1,str2,...)
Returns the string that results from concatenating the arguments. May
have one or more arguments. If all arguments are nonbinary strings, the
result is a nonbinary string. If the arguments include any binary
strings, the result is a binary string. A numeric argument is converted
to its equivalent string form. This is a nonbinary string as of MySQL
5.5.3. Before 5.5.3, it is a binary string; to to avoid that and
produce a nonbinary string, you can use an explicit type cast, as in
this example:
SELECT CONCAT(CAST(int_col AS CHAR), char_col);
CONCAT() returns NULL if any argument is NULL.
URL: http://dev.mysql.com/doc/refman/5.5/en/string-functions.html
Examples:
mysql> SELECT CONCAT('My', 'S', 'QL');
-> 'MySQL'
mysql> SELECT CONCAT('My', NULL, 'QL');
-> NULL
mysql> SELECT CONCAT(14.3);
-> '14.3'
又例如, 如果想查看create table的语法, 可以使用以下命令:
  1. mysql> ? create table
  2. Name: 'CREATE TABLE'
  3. Description:
  4. Syntax:
  5. CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
  6. (create_definition,...)
  7. [table_options]
  8. [partition_options]
  9. Or:
  10. CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
  11. [(create_definition,...)]
  12. [table_options]
  13. [partition_options]
  14. select_statement
  15. Or:
  16. CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
  17. { LIKE old_tbl_name | (LIKE old_tbl_name) }
  18. ......
mysql> ? create table
Name: 'CREATE TABLE'
Description:
Syntax:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
(create_definition,...)
[table_options]
[partition_options]
Or:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
[(create_definition,...)]
[table_options]
[partition_options]
select_statement
Or:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
{ LIKE old_tbl_name | (LIKE old_tbl_name) }
......
再举一个例子吧, 比如想查看创建用户GRANT语法怎么写
  1. mysql> ? grant
  2. Name: 'GRANT'
  3. Description:
  4. Syntax:
  5. GRANT
  6. priv_type [(column_list)]
  7. [, priv_type [(column_list)]] ...
  8. ON [object_type] priv_level
  9. TO user_specification [, user_specification] ...
  10. [REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}]
  11. [WITH with_option ...]
  12. GRANT PROXY ON user_specification
  13. TO user_specification [, user_specification] ...
  14. [WITH GRANT OPTION]
  15. object_type:
  16. TABLE
  17. | FUNCTION
  18. | PROCEDURE
  19. ......
mysql> ? grant
Name: 'GRANT'
Description:
Syntax:
GRANT
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
TO user_specification [, user_specification] ...
[REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}]
[WITH with_option ...]
GRANT PROXY ON user_specification
TO user_specification [, user_specification] ...
[WITH GRANT OPTION]
object_type:
TABLE
| FUNCTION
| PROCEDURE
......

下面把查看手册和官方资料的地址献上, 就把衣钵都传给你们了, 别忘了给个赞哦~网址:yii666.com<文章来源地址:https://www.yii666.com/article/332700.html

常用的网络资源

http://dev.mysql.com/downloads/是MySQL的官方网站,
可以下载到各个版本的MySQL以及相关客户端开发工具等.
http://dev.mysql.com/doc/提供了目前最权威的MySQL数据库及工具的在线手册
http://bugs.mysql.com/ 这里可以查看到MySQL已经发布的bug列表,
或者向MySQL提交bug报告
http://www.mysql.com/news-and-events/newsletter/通常会发布各种关于MySQL的最新消息.

版权声明:本文内容来源于网络,版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。文本页已经标记具体来源原文地址,请点击原文查看来源网址,站内文章以及资源内容站长不承诺其正确性,如侵犯了您的权益,请联系站长如有侵权请联系站长,将立刻删除

高效查看MySQL帮助文档的方法 (转)-相关文章

  1. postgresql 导出数据字典文档

    项目上需要整理目前数据库的数据字典文档。项目不规范,这种文档只要后期来补。这么多张表,每个字段都写到word文档里真心头大。就算前面写了个查询表结构的sql,但是最后整理到word里还是感觉有点麻烦。以前写过一个oracle直接生成表结构的html文档,所以现在也想再弄

  2. 高效查看MySQL帮助文档的方法 (转)

    在mysql的使用过程中, 可能经常会遇到以下问题:某个操作语法忘记了, 如何快速查找?如何快速知道当前版本上某个字段类型的取值范围?当前版本都支持哪些函数?希望有例子说明..当前版本是否支持某个功能?    对于上面列出的问题, 我们可能想到的方法是查找MySQL的文档, 这些

  3. MySQL帮助文档的使用

    帮助文档使用在 MySQL 使用过程中,可能经常会遇到以下问题:某个操作语法忘记了,需要快速查找。当前版本上,某个字段类型我们想快速知道它的取值范围?当前版本上,都支持哪些函数?希望有例子能快速入门。当前版本上,是否支持某个功能?对于上面列出的各种问题

  4. javadoc导出成word文档

    刚刚上次弄完了一个坑爹的任务,这次我领导又给我一个让人脑瓜子疼的任务了。基本上客户他在验收我们系统的时候,都会要求我们编写相关的文档,这次也不例外。只是这次的客户要求我们给出接口文档。不仅是要整个controller的rest接口文档,还要给出service层的接口,连

  5. 生成chm文档工具- Sandcastle -摘自网络

    Sandcastle是微软官方的文档生成工具,NDoc开发停止后,这个貌似也是唯一的一个这方面的工具。它从dll文件及其xml注释文件能够 生成完整的帮助文档,支持多种生成格式(Helpe1x:chm, Helper2x:Hxs, Website,HelperView),结合新发布的Sandcastle Help File Builder可视化工具,整个生成过程十分简单

  6. 如何在PowerDesigner将PDM导出生成WORD文档或者html文件

    a)         使用PowerDesigner打开pdm文件b)         点击Report Temlates 制作模板点击PowerDesigner菜单栏“Report” - “Report Templates”c)         选择模板数据项完成步骤a),得到如下界面,左右2个区,Aavailable区域中选择你想要在WORD文档中展示的数据项,这里我们选择List of T

  7. DataSet数据导出为Excel文档(每个DataTable为一个Sheet)

    Web项目中,很多时候须要实现将查询的数据集导出为Excel文档的功能,很多时候不希望在工程中添加对Office组件相关的DLL的引用,甚至有时候受到Office不同版本的影响,导致在不同的服务器上部署后功能受限,或和其它项目冲突,那么,使用这种简单粗暴的方式,可能会解决部

  8. API文档工具-Swagger的集成

    最近安装了API文档工具swagger,因为Github上已有详细安装教程,且安装过程中没有碰到大的阻碍,所以此文仅对这次安装做一份大致记录相关网站Swagger 官方地址:http://swagger.wordnik.comGithub安装详解【springmvc集成swagger】:https://github.com/rlogiacco/swagger-springmvc网上安装教程【可配合

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信图片_20190322181744_03.jpg

微信扫一扫打赏

请作者喝杯咖啡吧~

支付宝扫一扫领取红包,优惠每天领

二维码1

zhifubaohongbao.png

二维码2

zhifubaohongbao2.png