MySql 中文参考指南
1.1 About This Manual
这是 MySQL 数据库系统 9.0 版本(到 9.0.1 版本)的参考手册。通过引用版本号(9.0.x),在正文中记录了 MySQL 9.0 次要版本之间的差异。有关许可信息,请参阅 Legal Notices 。
This is the Reference Manual for the MySQL Database System, version 9.0, through release 9.0.1. Differences between minor versions of MySQL 9.0 are noted in the present text with reference to release numbers (9.0.x). For license information, see the Legal Notices.
由于 MySQL 9.0 与以前版本之间存在许多功能和其他差异,因此本手册不适用于较旧版本的 MySQL 软件。如果你使用的是较早版本的 MySQL 软件,请参阅相应的本手册。例如, MySQL 8.0 Reference Manual 介绍了 MySQL 软件发行版的 8.0 错误修补程序系列。
This manual is not intended for use with older versions of the MySQL software due to the many functional and other differences between MySQL 9.0 and previous versions. If you are using an earlier release of the MySQL software, please refer to the appropriate manual. For example, the MySQL 8.0 Reference Manual covers the 8.0 bugfix series of MySQL software releases.
由于本手册作为参考手册,因此,它不提供关于 SQL 或关系数据库概念的一般说明。它也不指导您如何使用自己的操作系统或命令行解释器。
Because this manual serves as a reference, it does not provide general instruction on SQL or relational database concepts. It also does not teach you how to use your operating system or command-line interpreter.
MySQL 数据库软件正在持续开发中,参考手册也在经常更新。最新版本的手册在以下网站上以可搜索的形式在线提供: [role="bare" [role="bare"]https://dev.mysql.com/doc/ )。那里还提供了其他格式,包括可下载的 HTML 和 PDF 版本。
The MySQL Database Software is under constant development, and the Reference Manual is updated frequently as well. The most recent version of the manual is available online in searchable form at [role="bare"https://dev.mysql.com/doc/]. Other formats also are available there, including downloadable HTML and PDF versions.
MySQL 本身的源代码包含使用 Doxygen 编写的内部文档。生成的 Doxygen 内容可从 [role="bare"[role="bare"]https://dev.mysql.com/doc/index-other.html] 获取。也可以使用 Section 2.8.10, “Generating MySQL Doxygen Documentation Content” 中的说明从 MySQL 源代码包本地生成此内容。
The source code for MySQL itself contains internal documentation written using Doxygen. The generated Doxygen content is available from [role="bare"https://dev.mysql.com/doc/index-other.html]. It is also possible to generate this content locally from a MySQL source distribution using the instructions at Section 2.8.10, “Generating MySQL Doxygen Documentation Content”.
如果您对使用 MySQL 有任何疑问,请加入 MySQL Community Slack。如果您对本手册本身的增补或更正有任何建议,请将其发送至 http://www.mysql.com/company/contact/。
If you have questions about using MySQL, join the MySQL Community Slack. If you have suggestions concerning additions or corrections to the manual itself, please send them to the http://www.mysql.com/company/contact/.
Typographical and Syntax Conventions
本手册使用某些印刷惯例:
This manual uses certain typographical conventions:
-
Text in this style is used for SQL statements; database, table, and column names; program listings and source code; and environment variables. Example: “To reload the grant tables, use the FLUSH PRIVILEGES statement.”
-
Text in this style indicates input that you type in examples.
-
Text in this style indicates the names of executable programs and scripts, examples being mysql (the MySQL command-line client program) and mysqld (the MySQL server executable).
-
Text in this style is used for variable input for which you should substitute a value of your own choosing.
-
Text in this style is used for emphasis.
-
Text in this style is used in table headings and to convey especially strong emphasis.
-
Text in this style is used to indicate a program option that affects how the program is executed, or that supplies information that is needed for the program to function in a certain way. Example: “The —host option (short form -h) tells the mysql client program the hostname or IP address of the MySQL server that it should connect to”.
-
File names and directory names are written like this: “The global my.cnf file is located in the /etc directory.”
-
Character sequences are written like this: “To specify a wildcard, use the ‘%’ character.”
当使用提示词作为命令或语句的前缀时,我们使用这些:
When commands or statements are prefixed by a prompt, we use these:
$> type a command here
#> type a command as root here
C:\> type a command here (Windows only)
mysql> type a mysql statement here
在命令解释器中发出命令。在 Unix 上,通常是一个名为 sh 、 csh 或 bash 的程序。在 Windows 上,等效程序为 command.com 或 cmd.exe ,通常在控制台窗口中运行。 mysql 为前缀的语句在 mysql 命令行客户端中发出。
Commands are issued in your command interpreter. On Unix, this is typically a program such as sh, csh, or bash. On Windows, the equivalent program is command.com or cmd.exe, typically run in a console window. Statements prefixed by mysql are issued in the mysql command-line client.
当您输入示例中显示的命令或语句时,请勿键入示例中显示的提示。 |
When you enter a command or statement shown in an example, do not type the prompt shown in the example. |
在某些区域,不同的系统之间可能会相互区别,以表明应在两个不同的环境中执行命令。例如,在使用复制时,命令可能加 source 和 replica 前缀:
In some areas different systems may be distinguished from each other to show that commands should be executed in two different environments. For example, while working with replication the commands might be prefixed with source and replica:
source> type a mysql statement on the replication source here
replica> type a mysql statement on the replica here
数据库、表和字段名称通常需要替代为语句。为了指明需要这种替代,本手册使用 db_name、tbl_name 和 col_name。例如,您可能看到类似这样的语句:
Database, table, and column names must often be substituted into statements. To indicate that such substitution is necessary, this manual uses db_name, tbl_name, and col_name. For example, you might see a statement like this:
mysql> SELECT col_name FROM db_name.tbl_name;
这意味着如果您要输入类似的语句,则需要提供您自己的数据库、表和字段名称,可能类似这样:
This means that if you were to enter a similar statement, you would supply your own database, table, and column names, perhaps like this:
mysql> SELECT author_name FROM biblio_db.author_list;
SQL 关键字不区分大小写,并且可以用任何字母大小写书写。本手册使用大写。
SQL keywords are not case-sensitive and may be written in any lettercase. This manual uses uppercase.
在语法描述中,方括号 (“[” 和 “]”) 表示可选的单词或从句。例如,在以下语句中,IF EXISTS 是可选的:
In syntax descriptions, square brackets (“[” and “]”) indicate optional words or clauses. For example, in the following statement, IF EXISTS is optional:
DROP TABLE [IF EXISTS] tbl_name
当语法元素由多个选项组成时,选项之间由竖线 (“|”) 分隔。当从选择 may 集合中选择一个成员时,将使用方括号 (“[” 和 “]”) 列出选项:
When a syntax element consists of a number of alternatives, the alternatives are separated by vertical bars (“|”). When one member from a set of choices may be chosen, the alternatives are listed within square brackets (“[” and “]”):
TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)
当一个成员_must_从一组选项中选择时,备选方案列在大括号中(“{”和“}”):
When one member from a set of choices must be chosen, the alternatives are listed within braces (“{” and “}”):
{DESCRIBE | DESC} tbl_name [col_name | wild]
省略号( … )表示省略了一部分语句,通常是为了提供更短的复杂语法版本。例如, SELECT … INTO OUTFILE 是 SELECT 语句的一种简写形式,该语句在该语句的其他部分后带有 INTO OUTFILE 子句。
An ellipsis (…) indicates the omission of a section of a statement, typically to provide a shorter version of more complex syntax. For example, SELECT … INTO OUTFILE is shorthand for the form of SELECT statement that has an INTO OUTFILE clause following other parts of the statement.
省略号还可能表示语句中前面的语法元素可以重复。在下面的示例中,可能会给出多个 reset_option 值,其中每个值后面的值之前带有逗号:
An ellipsis can also indicate that the preceding syntax element of a statement may be repeated. In the following example, multiple reset_option values may be given, with each of those after the first preceded by commas:
RESET reset_option [,reset_option] ...
用于设置 shell 变量的命令使用 Bourne shell 语法显示。例如,使用 Bourne shell 语法设置 CC 环境变量和运行 configure 命令的序列如下:
Commands for setting shell variables are shown using Bourne shell syntax. For example, the sequence to set the CC environment variable and run the configure command looks like this in Bourne shell syntax:
$> CC=gcc ./configure
如果您使用 csh 或 tcsh,您必须稍微不同地发出命令:
If you are using csh or tcsh, you must issue commands somewhat differently:
$> setenv CC gcc
$> ./configure
Manual Authorship
参考手册源文件采用 DocBook XML 格式编写。HTML 版本和其他格式主要是使用 DocBook XSL 样式表自动生成的。有关 DocBook 的信息,请参见 http://docbook.org/。
The Reference Manual source files are written in DocBook XML format. The HTML version and other formats are produced automatically, primarily using the DocBook XSL stylesheets. For information about DocBook, see http://docbook.org/
本手册最初由 David Axmark 和 Michael “Monty” Widenius 编写。它由 MySQL 文档团队(Edward Gilmore、Stefan Hinz、David Hollis、Philip Olson、Daniel So 和 Jon Stephens 组成)维护。
This manual was originally written by David Axmark and Michael “Monty” Widenius. It is maintained by the MySQL Documentation Team, consisting of Edward Gilmore, Stefan Hinz, David Hollis, Philip Olson, Daniel So, and Jon Stephens.