This section describes how MySQL relates to the ANSI/ISO SQL standards. MySQL Server has many extensions to the SQL standard, and here you can find out what they are and how to use them. You can also find information about functionality missing from MySQL Server, and how to work around some of the differences.本节介绍MySQL与ANSI/ISO SQL标准的关系。MySQL Server有许多SQL标准的扩展,在这里您可以了解它们是什么以及如何使用它们。您还可以找到有关MySQL Server缺少的功能的信息,以及如何解决其中的一些差异。
The SQL standard has been evolving since 1986 and several versions exist. SQL标准自1986年以来一直在发展,目前已有多个版本。In this manual, “SQL-92” refers to the standard released in 1992. “SQL:1999”, “SQL:2003”, “SQL:2008”, and “SQL:2011” refer to the versions of the standard released in the corresponding years, with the last being the most recent version. 在本手册中,“SQL-92”是指1992年发布的标准。“SQL:1999”、“SQL:2003”、“SQLServer:2008”和“SQL:2011”是指相应年份发布的标准版本,最后一个版本为最新版本。We use the phrase “the SQL standard” or “standard SQL” to mean the current version of the SQL Standard at any time.我们使用短语“SQL标准”或“标准SQL”来表示任何时候的SQL标准的当前版本。
One of our main goals with the product is to continue to work toward compliance with the SQL standard, but without sacrificing speed or reliability. We are not afraid to add extensions to SQL or support for non-SQL features if this greatly increases the usability of MySQL Server for a large segment of our user base. 我们使用该产品的主要目标之一是继续努力遵守SQL标准,但不牺牲速度或可靠性。如果这大大提高了MySQL Server对我们大部分用户的可用性,我们不怕为SQL添加扩展或支持非SQL功能。The HANDLER接口就是这种策略的一个例子。参见第13.2.4节,“处理方声明”。HANDLER
interface is an example of this strategy. See Section 13.2.4, “HANDLER Statement”.
We continue to support transactional and nontransactional databases to satisfy both mission-critical 24/7 usage and heavy Web or logging usage.我们继续支持事务性和非事务性数据库,以满足关键任务的全天候使用和繁重的Web或日志使用。
MySQL Server was originally designed to work with medium-sized databases (10-100 million rows, or about 100MB per table) on small computer systems. Today MySQL Server handles terabyte-sized databases.MySQL Server最初设计用于小型计算机系统上的中型数据库(1000万至1亿行,即每个表约100MB)。如今,MySQL Server处理TB大小的数据库。
We are not targeting real-time support, although MySQL replication capabilities offer significant functionality.尽管MySQL复制功能提供了重要的功能,但目标并不是实时支持。
MySQL supports ODBC levels 0 to 3.51.MySQL支持ODBC级别0到3.51。
MySQL supports high-availability database clustering using the MySQL支持使用NDBCLUSTER存储引擎的高可用性数据库集群。请参阅第23章,MySQL NDB Cluster 8.0。NDBCLUSTER
storage engine. See Chapter 23, MySQL NDB Cluster 8.0.
We implement XML functionality which supports most of the W3C XPath standard. See Section 12.12, “XML Functions”.我们实现了支持大部分W3C XPath标准的XML功能。请参阅第12.12节,“XML函数”。
MySQL supports a native JSON data type as defined by RFC 7159, and based on the ECMAScript standard (ECMA-262). MySQL支持RFC 7159定义的本地JSON数据类型,并基于ECMAScript标准(ECMA-262)。See Section 11.5, “The JSON Data Type”. 请参阅第11.5节,“JSON数据类型”。MySQL also implements a subset of the SQL/JSON functions specified by a pre-publication draft of the SQL:2016 standard; see Section 12.18, “JSON Functions”, for more information.MySQL还实现了SQL:2016标准发布前草案中指定的SQL/JSON函数的子集;有关更多信息,请参阅第12.18节,“JSON函数”。
The MySQL server can operate in different SQL modes, and can apply these modes differently for different clients, depending on the value of the MySQL服务器可以在不同的SQL模式下运行,并且可以根据sql_mode
system variable. sql_mode
系统变量的值将这些模式应用于不同的客户端。DBAs can set the global SQL mode to match site server operating requirements, and each application can set its session SQL mode to its own requirements.DBA可以设置全局SQL模式以匹配站点服务器的操作要求,并且每个应用程序可以根据自己的要求设置其会话SQL模式。
Modes affect the SQL syntax MySQL supports and the data validation checks it performs. This makes it easier to use MySQL in different environments and to use MySQL together with other database servers.模式会影响MySQL支持的SQL语法及其执行的数据验证检查。这使得在不同的环境中使用MySQL以及将MySQL与其他数据库服务器一起使用更容易。
For more information on setting the SQL mode, see Section 5.1.11, “Server SQL Modes”.有关设置SQL模式的更多信息,请参阅第5.1.11节,“服务器SQL模式”。
To run MySQL Server in ANSI mode, start mysqld with the 要在ANSI模式下运行MySQL Server,请使用--ansi
option. --ansi
选项启动mysqld。Running the server in ANSI mode is the same as starting it with the following options:在ANSI模式下运行服务器与使用以下选项启动服务器相同:
--transaction-isolation=SERIALIZABLE --sql-mode=ANSI
To achieve the same effect at runtime, execute these two statements:要在运行时实现相同的效果,请执行以下两条语句:
SET GLOBAL TRANSACTION ISOLATION LEVEL SERIALIZABLE; SET GLOBAL sql_mode = 'ANSI';
You can see that setting the 您可以看到,将sql_mode
system variable to 'ANSI'
enables all SQL mode options that are relevant for ANSI mode as follows:sql_mode
系统变量设置为“ANSI”将启用与ANSI模式相关的所有sql模式选项,如下所示:
mysql>SET GLOBAL sql_mode='ANSI';
mysql>SELECT @@GLOBAL.sql_mode;
-> 'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI'
Running the server in ANSI mode with 使用--ansi
is not quite the same as setting the SQL mode to 'ANSI'
because the --ansi
option also sets the transaction isolation level.--ansi
以ANSI模式运行服务器与将SQL模式设置为'ANSI'
并不完全相同,因为--ansi
选项还设置事务隔离级别。
See Section 5.1.7, “Server Command Options”.请参阅第5.1.7节,“服务器命令选项”。