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

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

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


 

按层次查看帮助

查看目录    

如果不知道帮助能够提供些什么, 可以用"? contents"命令来显示所有可供查询的分类, 如下例所示:
[sql]  view plain  copy
  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都支持哪些数据类型, 可以执行"? data tyeps"命令:
[sql]  view plain  copy
  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  
上面列出了此版本支持的所有数据类型, 如果想知道int类型的具体介绍, 也可以利用上面的方法, 做进一步的查看:
[sql]  view plain  copy
  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  

查看函数

[sql]  view plain  copy
  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  
再根据列出的目录查看相应函数,比如查看都有什么日期函数
[sql]  view plain  copy
  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  

 

快速查阅帮助

    在实际应用当中, 如果需要快速查阅某项语法时, 可以使用关键字进行快速查询. 例如, 想知道show命令都能看到什么东西, 可以用如下命令:
[sql]  view plain  copy
  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  
例如, 想查看某个函数CONCAT的使用
[sql]  view plain  copy
  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 castas 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'  
又例如, 如果想查看create table的语法, 可以使用以下命令:
[sql]  view plain  copy
  1. mysql> ? create table  
  2. Name'CREATE TABLE'  
  3. Description:  
  4. Syntax:  
  5. CREATE [TEMPORARYTABLE [IF NOT EXISTS] tbl_name  
  6.     (create_definition,...)  
  7.     [table_options]  
  8.     [partition_options]  
  9. Or:  
  10. CREATE [TEMPORARYTABLE [IF NOT EXISTS] tbl_name  
  11.     [(create_definition,...)]  
  12.     [table_options]  
  13.     [partition_options]  
  14.     select_statement  
  15. Or:  
  16. CREATE [TEMPORARYTABLE [IF NOT EXISTS] tbl_name  
  17.     { LIKE old_tbl_name | (LIKE old_tbl_name) }  
  18.     ......  
再举一个例子吧, 比如想查看创建用户GRANT语法怎么写
[sql]  view plain  copy
  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.       ......  

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

 

常用的网络资源

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的最新消息.


转载自以下地址:https://blog.csdn.net/caomiao2006/article/details/52016959

猜你喜欢

转载自blog.csdn.net/sehejs_a/article/details/80455858
今日推荐