1.7.1 MySQL Extensions to Standard SQLMySQL对标准SQL的扩展

MySQL Server supports some extensions that you are not likely to find in other SQL DBMSs. MySQL Server支持一些在其他SQL数据库管理系统中找不到的扩展。Be warned that if you use them, your code is most likely not portable to other SQL servers. 请注意,如果您使用它们,您的代码很可能无法移植到其他SQL服务器。In some cases, you can write code that includes MySQL extensions, but is still portable, by using comments of the following form:在某些情况下,您可以使用以下形式的注释来编写包含MySQL扩展但仍然可移植的代码:

/*! MySQL-specific code */

In this case, MySQL Server parses and executes the code within the comment as it would any other SQL statement, but other SQL servers should ignore the extensions. 在这种情况下,MySQL Server会像解析任何其他SQL语句一样解析并执行注释中的代码,但其他SQL服务器应该忽略扩展。For example, MySQL Server recognizes the STRAIGHT_JOIN keyword in the following statement, but other servers should not:例如,MySQL Server可以识别以下语句中的STRIGHT_JOIN关键字,但其他服务器不应该识别:

SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE ...

If you add a version number after the ! character, the syntax within the comment is executed only if the MySQL version is greater than or equal to the specified version number. 如果在之后添加版本号!字符,只有当MySQL版本大于或等于指定的版本号时,才会执行注释中的语法。The KEY_BLOCK_SIZE clause in the following comment is executed only by servers from MySQL 5.1.10 or higher:以下注释中的KEY_BLOCK_SIZE子句仅由MySQL 5.1.10或更高版本的服务器执行:

CREATE TABLE t1(a INT, KEY (a)) /*!50110 KEY_BLOCK_SIZE=1024 */;

The following descriptions list MySQL extensions, organized by category.以下描述按类别列出了MySQL扩展。