帮助文档使用

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

  • 某个操作语法忘记了,需要快速查找。
  • 当前版本上,某个字段类型我们想快速知道它的取值范围?
  • 当前版本上,都支持哪些函数?希望有例子能快速入门。
  • 当前版本上,是否支持某个功能?

对于上面列出的各种问题,我们可能想到的办法是查找 MySQL 的文档。不错,这些问题在 MySQL 官方文档中都可以很清楚地查到,但是却要耗费大量的时间和精力。 所以对于以上问题,最好的解决办法是使用 MySQL 安装后自带的帮助文档,这样在遇到问 题时就可以方便快捷地进行查询。

  1. 按照层次看帮助

    如果不知道帮助能够提供些什么,可以用“?contents”命令来显示所有可供查询的的分类, 如下例所示:

    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 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 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类型的具体介绍,也可以使用上忙的方法,做进一步的查看:

    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.6/en/numeric-type-overview.html

    帮助文档中显示了 int 类型的详细描述。通过这种“? 类别名称”的方式,就可以一层层 地往下查找用户所关心的主题内容。

  2. 快速查阅帮助

    在实际应用当中,如果需要快速查阅某项语法时,可以使用关键字进行快速查询。例如,想 知道 show 命令都能看些什么东西,可以用如下命令:

    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 RELAYLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]
    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.6/en/extended-show.html. URL: http://dev.mysql.com/doc/refman/5.6/en/show.html

    例如,如果想参看CREATE TABLE 的语法,可以使用以下命令:

    mysql> ? create table
    Name: 'CREATE TABLE'
    Description:
    Syntax:
    CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    (create_definition,...)
    [table_options]
    [partition_options] CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    [(create_definition,...)]
    [table_options]
    [partition_options]
    [IGNORE | REPLACE]
    [AS] query_expression CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name
    { LIKE old_tbl_name | (LIKE old_tbl_name) } create_definition:
    col_name column_definition
    | [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...)
    [index_option] ...
    | {INDEX|KEY} [index_name] [index_type] (index_col_name,...)
    [index_option] ...
    | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY]
    [index_name] [index_type] (index_col_name,...)
    [index_option] ...
    | {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...)
    [index_option] ...
    | [CONSTRAINT [symbol]] FOREIGN KEY
    [index_name] (index_col_name,...) reference_definition
    | CHECK (expr) column_definition:
    data_type [NOT NULL | NULL] [DEFAULT default_value]
    [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY]
    [COMMENT 'string']
    [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}]
    [STORAGE {DISK|MEMORY|DEFAULT}]
    [reference_definition] data_type:
    BIT[(length)]
    | TINYINT[(length)] [UNSIGNED] [ZEROFILL]
    | SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
    | MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
    | INT[(length)] [UNSIGNED] [ZEROFILL]
    | INTEGER[(length)] [UNSIGNED] [ZEROFILL]
    | BIGINT[(length)] [UNSIGNED] [ZEROFILL]
    | REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
    | DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
    | FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
    | DECIMAL[(length[,decimals])] [UNSIGNED] [ZEROFILL]
    | NUMERIC[(length[,decimals])] [UNSIGNED] [ZEROFILL]
    | DATE
    | TIME[(fsp)]
    | TIMESTAMP[(fsp)]
    | DATETIME[(fsp)]
    | YEAR
    | CHAR[(length)] [BINARY]
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | VARCHAR(length) [BINARY]
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | BINARY[(length)]
    | VARBINARY(length)
    | TINYBLOB
    | BLOB
    | MEDIUMBLOB
    | LONGBLOB
    | TINYTEXT [BINARY]
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | TEXT [BINARY]
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | MEDIUMTEXT [BINARY]
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | LONGTEXT [BINARY]
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | ENUM(value1,value2,value3,...)
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | SET(value1,value2,value3,...)
    [CHARACTER SET charset_name] [COLLATE collation_name]
    | spatial_type index_col_name:
    col_name [(length)] [ASC | DESC] index_type:
    USING {BTREE | HASH} index_option:
    KEY_BLOCK_SIZE [=] value
    | index_type
    | WITH PARSER parser_name
    | COMMENT 'string' reference_definition:
    REFERENCES tbl_name (index_col_name,...)
    [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE]
    [ON DELETE reference_option]
    [ON UPDATE reference_option] reference_option:
    RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT table_options:
    table_option [[,] table_option] ... table_option:
    ENGINE [=] engine_name
    | AUTO_INCREMENT [=] value
    | AVG_ROW_LENGTH [=] value
    | [DEFAULT] CHARACTER SET [=] charset_name
    | CHECKSUM [=] {0 | 1}
    | [DEFAULT] COLLATE [=] collation_name
    | COMMENT [=] 'string'
    | CONNECTION [=] 'connect_string'
    | DATA DIRECTORY [=] 'absolute path to directory'
    | DELAY_KEY_WRITE [=] {0 | 1}
    | INDEX DIRECTORY [=] 'absolute path to directory'
    | INSERT_METHOD [=] { NO | FIRST | LAST }
    | KEY_BLOCK_SIZE [=] value
    | MAX_ROWS [=] value
    | MIN_ROWS [=] value
    | PACK_KEYS [=] {0 | 1 | DEFAULT}
    | PASSWORD [=] 'string'
    | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT}
    | STATS_AUTO_RECALC [=] {DEFAULT|0|1}
    | STATS_PERSISTENT [=] {DEFAULT|0|1}
    | STATS_SAMPLE_PAGES [=] value
    | TABLESPACE tablespace_name [STORAGE {DISK|MEMORY|DEFAULT}]
    | UNION [=] (tbl_name[,tbl_name]...) partition_options:
    PARTITION BY
    { [LINEAR] HASH(expr)
    | [LINEAR] KEY [ALGORITHM={1|2}] (column_list)
    | RANGE{(expr) | COLUMNS(column_list)}
    | LIST{(expr) | COLUMNS(column_list)} }
    [PARTITIONS num]
    [SUBPARTITION BY
    { [LINEAR] HASH(expr)
    | [LINEAR] KEY [ALGORITHM={1|2}] (column_list) }
    [SUBPARTITIONS num]
    ]
    [(partition_definition [, partition_definition] ...)] partition_definition:
    PARTITION partition_name
    [VALUES
    {LESS THAN {(expr | value_list) | MAXVALUE}
    |
    IN (value_list)}]
    [[STORAGE] ENGINE [=] engine_name]
    [COMMENT [=] 'comment_text' ]
    [DATA DIRECTORY [=] 'data_dir']
    [INDEX DIRECTORY [=] 'index_dir']
    [MAX_ROWS [=] max_number_of_rows]
    [MIN_ROWS [=] min_number_of_rows]
    [TABLESPACE [=] tablespace_name]
    [NODEGROUP [=] node_group_id]
    [(subpartition_definition [, subpartition_definition] ...)] subpartition_definition:
    SUBPARTITION logical_name
    [[STORAGE] ENGINE [=] engine_name]
    [COMMENT [=] 'comment_text' ]
    [DATA DIRECTORY [=] 'data_dir']
    [INDEX DIRECTORY [=] 'index_dir']
    [MAX_ROWS [=] max_number_of_rows]
    [MIN_ROWS [=] min_number_of_rows]
    [TABLESPACE [=] tablespace_name]
    [NODEGROUP [=] node_group_id] query_expression:
    SELECT ... (Some valid select or union statement) CREATE TABLE creates a table with the given name. You must have the
    CREATE privilege for the table. By default, tables are created in the default database, using the
    InnoDB storage engine. An error occurs if the table exists, if there is
    no default database, or if the database does not exist. For information about the physical representation of a table, see
    http://dev.mysql.com/doc/refman/5.6/en/create-table-files.html. URL: http://dev.mysql.com/doc/refman/5.6/en/create-table.html
  3. 常用的网络资源

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

小结:

本章简单地介绍了 SQL 语句的基本分类 DML/DDL/DCL,并对每一种分类下的常用 SQL 的用 法进行了举例说明。MySQL 在标准 SQL 的基础上进行了很多扩展,本章对常用的一些语法 做了简单介绍,更详细的说明,读者可以参考 MySQL 的帮助或者官方文档。在本章的最后, 还介绍了用户应如何使用 MySQL 中的帮助文档,以便快速查找各种语法定义

MySQL帮助文档的使用的更多相关文章

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

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

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

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

  3. [转载]linux+nginx+python+mysql安装文档

    原文地址:linux+nginx+python+mysql安装文档作者:oracletom # 开发包(如果centos没有安装数据库服务,那么要安装下面的mysql开发包) MySQL-devel- ...

  4. 基于Mybatis的Mysql数据库文档生成工具,支持生成docx(原创)

    今天不写android--也写写数据库相关的东西 -------------------- 今日老夫闲来无事,设计了一款数据库文档生成工具 眼下仅仅支持mysql 主要是生成docx的 下载链接:下载 ...

  5. MySQL相关文档索引

    MySQL的新功能5.7 https://dev.mysql.com/doc/refman/5.7/en/mysql-nutshell.html MySQL5.7安装 http://note.youd ...

  6. MySQL安装指导文档

    MySQL 是最流行的关系型数据库管理系统,可以在本地搭建一个mysql的环境,便于学习. windows7/windows10 5.7.26 安装mysql前环境准备工作 1) 要有Net fram ...

  7. 使用Sed抽取MySQL安装文档的目录及行号

    sed -nr  -e '/^2.|^shell/=' -e '/^2.|^shell/p' INSTALL-SOURCE |awk '{if (NR%2==1) x=$1; else printf ...

  8. mysql插入文本文档及读取

    1.把本地的一个文件插入到数据库中,数据库字段用text保存 public static void main(String[] args) { PropKit.use(“pro.txt”);Druid ...

  9. mysql设置文档快捷写

    select distinct column_name,column_comment,column_type from information_schema.columns where table_n ...

随机推荐

  1. 牛客小白赛4 C题

    乘法逆元: 一个数a 乘上 b,在mod之后再还原成本来的数 a 这里就要用到乘法逆元,(a*b)%mod*inv(b,mod)==a ll exgcd(ll a,ll b,ll &x,ll ...

  2. 消息队列(五)--- RocketMQ-消息存储2

    概述 RocketMQ存储中主要用到以下知识点: mmap 文件映射 内存池 异步刷盘 consumeQueue 同时本节将介绍各个重要的类,本篇文章将介绍 mmap 文件映射的相关方法和内存池相关知 ...

  3. 拥抱高通的联想,真的能靠5G突围?

    编辑 | 于斌 出品 | 于见(mpyujian) 2016年,对于常年自我标榜为"民族企业"的联想来说是品牌口碑的"转折之年".它在这一年的5G信道编码标准方 ...

  4. C# 动态类型 以及 脚本调用(scriptRunTime)

    在使用中让我感觉 好像 JavaScript中的 动态类型囧 先看动态类型 class Program { static void Main(string[] args) { var streamRe ...

  5. C# 抗变与协变的理解

    我们知道 方法的参数是协变的: void display(shape o) 如果类Rectangle 继承于shape类,那我们可以给该方法传入Rectangle类的实例. 而方法的返回类型是抗变的, ...

  6. 手把手教你使用Hexo+GitHub搭建自己的个人博客网站

    安装nodejs环境 这个直接搜索安装即可,安装完成之后,通过如下命令检测环境变量是否安装成功: λ node -v # 输出版本号 v12.13.1 正确输入版本号即可. 安装cnpm cnpm是淘 ...

  7. 24 JavaScript对象访问器&JavaScript对象构造器

    ES5引入了Getter和Setter Getter和Setter允许定义对象访问器 JavaScript Getter(get关键字):获取对象属性 <script> var perso ...

  8. Codeforces Round #611 (Div. 3) E

    Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past ...

  9. Codeforces Round #600 (Div. 2) - D. Harmonious Graph(并查集)

    题意:对于一张图,如果$a$与$b$连通,则对于任意的$c(a<c<b)$都有$a$与$c$连通,则称该图为和谐图,现在给你一张图,问你最少添加多少条边使图变为和谐图. 思路:将一个连通块 ...

  10. C++11常用特性介绍——array容器

    std::array是具有固定大小的数组,支持快速随机访问,不能添加或删除元素,定义于头文件<array>中. 一.概要 array是C++11新引入的容器类型,与内置数组相比,array ...