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

在mysql的使用过程中, 可能经常会遇到以下问题:

  • 某个操作语法忘记了, 如何快速查找?
  • 如何快速知道当前版本上某个字段类型的取值范围?
  • 当前版本都支持哪些函数?希望有例子说明..
  • 当前版本是否支持某个功能?
    对于上面列出的问题, 我们可能想到的方法是查找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
......

下面把查看手册和官方资料的地址献上, 就把衣钵都传给你们了, 别忘了给个赞哦~

常用的网络资源

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的最新消息.
上一篇:基于MVC4+EasyUI的Web开发框架经验总结(13)--DataGrid控件实现自动适应宽带高度


下一篇:ubuntu 16.04下使用 python pip的安装问题。