8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

正文为中文,英文原文默认隐藏。点击任意中文段落即可展开 / 收起对应英文原文。

打开官方英文原文 ↗

译文由机器翻译生成,仅供理解参考;有疑问请以官方英文原文为准。

MySQL 8.4 参考手册 / 1 一般信息 / 1.1 关于本手册
中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 100%

1.1 关于本手册1.1 About This Manual

这是 MySQL 数据库系统 8.4 版至 8.4.9 版的参考手册。 MySQL 8.4 次要版本之间的差异在本文中参考版本号 (8.4.x) 进行了说明。有关许可证信息,请参阅法律声明。This is the Reference Manual for the MySQL Database System, version 8.4, through release 8.4.9. Differences between minor versions of MySQL 8.4 are noted in the present text with reference to release numbers (8.4.x). For license information, see the Legal Notices.

由于 MySQL 8.4 与以前版本之间存在许多功能和其他差异,因此本手册不适用于旧版本的 MySQL 软件。如果您使用的是早期版本的 MySQL 软件,请参阅相应的手册。例如,MySQL 8.0 参考手册涵盖了 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 8.4 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 数据库软件正在不断开发,参考手册也经常更新。该手册的最新版本可在 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 https://dev.mysql.com/doc/. Other formats also are available there, including downloadable HTML and PDF versions.

MySQL 的源代码本身包含使用 Doxygen 编写的内部文档。生成的 Doxygen 内容可从 https://dev.mysql.com/doc/index-other.html 获取。还可以使用第 2.8.10 节“生成 MySQL Doxygen 文档内容”中的说明从 MySQL 源代码分发本地生成此内容。The source code for MySQL itself contains internal documentation written using Doxygen. The generated Doxygen content is available from 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 社区 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用于 SQL 语句;数据库、表和列名称;程序清单和源代码;和环境变量。示例:“要重新加载授权表,请使用FLUSH PRIVILEGES语句。”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表示您键入的输入Text in this style indicates input that you type in examples.

  • 这种风格的文本表示可执行程序和脚本的名称,例如mysql(MySQL 命令行客户端程序)和mysqld(MySQL 服务器可执行文件)。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用于变量输入,您应替换为您自己选择的值。Text in this style is used for variable input for which you should substitute a value of your own choosing.

  • 此样式中的文本 style 用于强调。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用于指示影响程序执行方式的程序选项,或提供程序以某种方式运行所需的信息。 示例:“--host选项(缩写形式-h)告诉mysql 客户端程序应连接到的 MySQL 服务器的主机名或 IP 地址”。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”.

  • 文件名和目录名如下所示: “全局 my.cnf 文件位于 /etc目录。”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.

Note

当您输入示例中所示的命令或语句时,请勿键入示例中所示的提示符。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

当语法元素由多个替代项组成时,替代项之间用竖线分隔(“|”)。当从一组选项可能中选择一个成员时,替代方案会在方括号内列出(“[”和“]”):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)

When one member from a set of choices 必须 be chosen, the alternatives are listed within braces (“{”以及“}”):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 语法显示。例如,设置 CC 环境变量并运行 configure 命令的顺序在 Bourne shell 语法中如下所示: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、Sudharsana Gomadam、Kim seong Loh、Garima Sharma、Carlos Ortiz、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, Sudharsana Gomadam, Kim seong Loh, Garima Sharma, Carlos Ortiz, Daniel So, and Jon Stephens.