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

来源:互联网 发布:开一个网络主播工作室 编辑:程序博客网 时间:2024/04/30 19:56

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

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

按层次查看帮助

查看目录    

如果不知道帮助能够提供些什么, 可以用"? contents"命令来显示所有可供查询的分类, 如下例所示:
mysql> ? contentsYou asked for help about help category: "Contents"For more information, type 'help <item>', where <item> is one of the followingcategories:   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"命令:
mysql> ? data typesYou asked for help about help category: "Data Types"For more information, type 'help <item>', where <item> is one of the followingtopics:   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类型的具体介绍, 也可以利用上面的方法, 做进一步的查看:
mysql> ? intName: '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

查看函数

mysql> ? functionsYou asked for help about help category: "Functions"For more information, type 'help <item>', where <item> is one of the followingcategories:   Bit Functions   Comparison operators   Control flow functions   Date and Time Functions   Encryption Functions   Information Functions   Logical operators   Miscellaneous Functions   Numeric Functions   String Functions
再根据列出的目录查看相应函数,比如查看都有什么日期函数
mysql> ? Date and Time FunctionsYou asked for help about help category: "Date and Time Functions"For more information, type 'help <item>', where <item> is one of the followingtopics:   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命令都能看到什么东西, 可以用如下命令:
mysql> ? showName: 'SHOW'Description:SHOW has many forms that provide information about databases, tables,columns, or status information about the server. This section describesthose following:SHOW AUTHORSSHOW {BINARY | MASTER} LOGSSHOW 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 CONTRIBUTORSSHOW CREATE DATABASE db_nameSHOW CREATE EVENT event_nameSHOW CREATE FUNCTION func_nameSHOW CREATE PROCEDURE proc_nameSHOW CREATE TABLE tbl_nameSHOW CREATE TRIGGER trigger_nameSHOW CREATE VIEW view_nameSHOW DATABASES [like_or_where]SHOW ENGINE engine_name {STATUS | MUTEX}SHOW [STORAGE] ENGINESSHOW ERRORS [LIMIT [offset,] row_count]SHOW EVENTSSHOW FUNCTION CODE func_nameSHOW FUNCTION STATUS [like_or_where]SHOW GRANTS FOR userSHOW INDEX FROM tbl_name [FROM db_name]SHOW MASTER STATUSSHOW OPEN TABLES [FROM db_name] [like_or_where]SHOW PLUGINSSHOW PROCEDURE CODE proc_nameSHOW PROCEDURE STATUS [like_or_where]SHOW PRIVILEGESSHOW [FULL] PROCESSLISTSHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n]SHOW PROFILESSHOW SLAVE HOSTSSHOW SLAVE STATUSSHOW [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 exprIf 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 statementoutput to matching values.Several SHOW statements also accept a WHERE clause that provides moreflexibility in specifying which rows to display. Seehttp://dev.mysql.com/doc/refman/5.5/en/extended-show.html.URL: http://dev.mysql.com/doc/refman/5.5/en/show.html
例如, 想查看某个函数CONCAT的使用
mysql> ? concatName: 'CONCAT'Description:Syntax:CONCAT(str1,str2,...)Returns the string that results from concatenating the arguments. Mayhave one or more arguments. If all arguments are nonbinary strings, theresult is a nonbinary string. If the arguments include any binarystrings, the result is a binary string. A numeric argument is convertedto its equivalent string form. This is a nonbinary string as of MySQL5.5.3. Before 5.5.3, it is a binary string; to to avoid that andproduce a nonbinary string, you can use an explicit type cast, as inthis 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.htmlExamples:mysql> SELECT CONCAT('My', 'S', 'QL');        -> 'MySQL'mysql> SELECT CONCAT('My', NULL, 'QL');        -> NULLmysql> SELECT CONCAT(14.3);        -> '14.3'
又例如, 如果想查看create table的语法, 可以使用以下命令:
mysql> ? create tableName: '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_statementOr:CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name    { LIKE old_tbl_name | (LIKE old_tbl_name) }    ......
再举一个例子吧, 比如想查看创建用户GRANT语法怎么写
mysql> ? grantName: '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的最新消息.
0 0
原创粉丝点击