使用MySQL帮助

来源:互联网 发布:sql语句 数据类型 编辑:程序博客网 时间:2024/06/07 23:23

在实际工作中可能会涉及到不同的数据库,就是使用相同的数据库,可能也会涉及到不同版本,那么在这样的情况下有些命令或者语法可能就会因为不同的版本产生变化,所以为了方便查询不同版本下面的命令或者语法,MySQL产品专门提供了各自的帮助文档。

首先使用? contents查看MySQL提供帮助分类:

mysql> ? contents;You 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

以上命令列出了一个列表,其中一项为Data Types,假设要看一下提供的数据类型又包含哪些:

mysql> ? Data Types;You 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

数据类型列表出来了,那再看看具体的数据类型是啥情况,比如看看BIGINT:

mysql> ? BIGINT;Name: 'BIGINT'Description:BIGINT[(M)] [UNSIGNED] [ZEROFILL]A large integer. The signed range is -9223372036854775808 to9223372036854775807. The unsigned range is 0 to 18446744073709551615.SERIAL is an alias for BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE.URL: http://dev.mysql.com/doc/refman/5.7/en/numeric-type-overview.html

这里看到了BIGINT的有符号时候的范围与无符号时候的范围,最后还给了个官方网站的链接。

再看看关于账号管理有啥内容:

mysql> ? Account ManagementYou asked for help about help category: "Account Management"For more information, type 'help <item>', where <item> is one of the followingtopics:   ALTER USER   CREATE USER   DROP USER   GRANT   RENAME USER   REVOKE   SET PASSWORD

看一下Insert咋用:

? insertName: 'INSERT'Description:Syntax:INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]    [INTO] tbl_name    [PARTITION (partition_name,...)]    [(col_name,...)]    {VALUES | VALUE} ({expr | DEFAULT},...),(...),...    [ ON DUPLICATE KEY UPDATE      col_name=expr        [, col_name=expr] ... ]Or:INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]    [INTO] tbl_name    [PARTITION (partition_name,...)]    SET col_name={expr | DEFAULT}, ...    [ ON DUPLICATE KEY UPDATE      col_name=expr        [, col_name=expr] ... ]Or:INSERT [LOW_PRIORITY | HIGH_PRIORITY] [IGNORE]    [INTO] tbl_name    [PARTITION (partition_name,...)]    [(col_name,...)]    SELECT ...    [ ON DUPLICATE KEY UPDATE      col_name=expr        [, col_name=expr] ... ]INSERT inserts new rows into an existing table. The INSERT ... VALUESand INSERT ... SET forms of the statement insert rows based onexplicitly specified values. The INSERT ... SELECT form inserts rowsselected from another table or tables. INSERT ... SELECT is discussedfurther in [HELP INSERT SELECT].When inserting into a partitioned table, you can control whichpartitions and subpartitions accept new rows. The PARTITION optiontakes a comma-separated list of the names of one or more partitions orsubpartitions (or both) of the table. If any of the rows to be insertedby a given INSERT statement do not match one of the partitions listed,the INSERT statement fails with the error Found a row not matching thegiven partition set. Seehttp://dev.mysql.com/doc/refman/5.7/en/partitioning-selection.html, formore information and examples.In MySQL 5.7, the DELAYED keyword is accepted but ignored by theserver. See [HELP INSERT DELAYED], for the reasons for this.URL: http://dev.mysql.com/doc/refman/5.7/en/insert.html

看看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 {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 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 RELAYLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]SHOW SLAVE HOSTSSHOW SLAVE STATUS [NONBLOCKING]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 exprIf the syntax for a given SHOW statement includes a LIKE 'pattern'part, 'pattern' is a string that can contain the SQL % and _ wildcardcharacters. The pattern is useful for restricting statement output tomatching 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.7/en/extended-show.html.URL: http://dev.mysql.com/doc/refman/5.7/en/show.html

总之这么做就是为了更方便去查询对应版本的语法。

原创粉丝点击