本节介绍 MySQL 数据库软件的一些重要特性。在大多数方面,该路线图适用于 MySQL 的所有版本。有关特定于系列的 MySQL 中引入的功能的信息,请参阅相应手册的“简而言之”部分:This section describes some of the important characteristics of the MySQL Database Software. In most respects, the roadmap applies to all versions of MySQL. For information about features as they are introduced into MySQL on a series-specific basis, see the “In a Nutshell” section of the appropriate Manual:
MySQL 8.4:第 1.4 节,“MySQL 8.4 中的新增功能” MySQL 8.4 自 MySQL 8.0”MySQL 8.4: Section 1.4, “What Is New in MySQL 8.4 since MySQL 8.0”
MySQL 8.0:MySQL 8.0 中的新增功能MySQL 8.0: What Is New in MySQL 8.0
MySQL 5.7:MySQL 5.7 中的新增功能MySQL 5.7: What Is New in MySQL 5.7
内部结构和可移植性Internals and Portability
用 C 和 C++。Written in C and C++.
使用多种不同的编译器进行测试。Tested with a broad range of different compilers.
适用于许多不同的平台。请参阅 https://www.mysql.com/support/supportedplatforms/database.html。Works on many different platforms. See https://www.mysql.com/support/supportedplatforms/database.html.
为了可移植性,使用 CMake 进行配置。For portability, configured using CMake.
使用 Purify(商业内存泄漏检测器)以及 Valgrind,一种 GPL 工具(https://valgrind.org/)。Tested with Purify (a commercial memory leakage detector) as well as with Valgrind, a GPL tool (https://valgrind.org/).
使用具有独立模块的多层服务器设计。Uses multi-layered server design with independent modules.
设计为使用内核线程的完全多线程,以便轻松使用多个可用的 CPU。Designed to be fully multithreaded using kernel threads, to easily use multiple CPUs if they are available.
提供事务性和非事务性存储引擎。Provides transactional and nontransactional storage engines.
使用非常快的 B 树磁盘表 (
MyISAM) 和索引压缩。Uses very fast B-tree disk tables (MyISAM) with index compression.旨在使添加其他存储引擎相对容易。如果您想为内部数据库提供 SQL 接口,这非常有用。Designed to make it relatively easy to add other storage engines. This is useful if you want to provide an SQL interface for an in-house database.
使用非常快速的基于线程的内存分配系统。Uses a very fast thread-based memory allocation system.
使用优化的嵌套循环连接执行非常快速的连接。Executes very fast joins using an optimized nested-loop join.
实现内存中哈希表,用作临时表。Implements in-memory hash tables, which are used as temporary tables.
使用高度优化的类库实现 SQL 函数,该类库应该尽可能快。通常,查询初始化后根本没有内存分配。Implements SQL functions using a highly optimized class library that should be as fast as possible. Usually there is no memory allocation at all after query initialization.
将服务器作为单独的程序提供,以便在客户端/服务器网络环境中使用。Provides the server as a separate program for use in a client/server networked environment.
数据类型Data Types
多种数据类型:有符号/无符号整数 1、2、3、4 和 8 字节长、
FLOAT、DOUBLE、CHAR、VARCHAR、BINARY、VARBINARY、TEXT、BLOB、DATE、TIME、DATETIME、TIMESTAMP、YEAR、SET、ENUM和 OpenGIS 空间类型。请参阅第 13 章,数据类型。Many data types: signed/unsigned integers 1, 2, 3, 4, and 8 bytes long,FLOAT,DOUBLE,CHAR,VARCHAR,BINARY,VARBINARY,TEXT,BLOB,DATE,TIME,DATETIME,TIMESTAMP,YEAR,SET,ENUM, and OpenGIS spatial types. See Chapter 13, Data Types.固定长度和可变长度字符串类型。Fixed-length and variable-length string types.
语句和函数Statements and Functions
SELECT查询列表和WHERE子句。例如:Full operator and function support in theSELECTlist andWHEREclause of queries. For example:mysql>
SELECT CONCAT(first_name, ' ', last_name)->FROM citizen->WHERE income/dependents > 10000 AND age > 30;完全支持 SQL
GROUP BY和ORDER BY子句。支持组函数(COUNT()、AVG()、STD()、SUM()、MAX()、MIN()和GROUP_CONCAT())。Full support for SQLGROUP BYandORDER BYclauses. Support for group functions (COUNT(),AVG(),STD(),SUM(),MAX(),MIN(), andGROUP_CONCAT()).支持标准 SQL 和 ODBC 的
LEFT OUTER JOIN和RIGHT OUTER JOIN语法。Support forLEFT OUTER JOINandRIGHT OUTER JOINwith both standard SQL and ODBC syntax.支持标准 SQL 所需的表和列别名。Support for aliases on tables and columns as required by standard SQL.
支持
DELETE、INSERT、REPLACE和UPDATE返回已更改(受影响)的行数,或通过在连接时设置标志来返回匹配的行数Support forDELETE,INSERT,REPLACE, andUPDATEto return the number of rows that were changed (affected), or to return the number of rows matched instead by setting a flag when connecting to the server.支持特定于 MySQL 的
SHOW语句,用于检索有关数据库、存储引擎、表和索引的信息。支持根据标准 SQL 实现的INFORMATION_SCHEMA数据库。Support for MySQL-specificSHOWstatements that retrieve information about databases, storage engines, tables, and indexes. Support for theINFORMATION_SCHEMAdatabase, implemented according to standard SQL.EXPLAIN语句,用于显示优化器如何解析查询。AnEXPLAINstatement to show how the optimizer resolves a query.函数名称与表或列名称的独立性。例如,
ABS是有效的列名称。唯一的限制是,对于函数调用,函数名称与其后面的 “(” 之间不允许有空格。请参阅第 11.3 节“关键字和保留字”。Independence of function names from table or column names. For example,ABSis a valid column name. The only restriction is that for a function call, no spaces are permitted between the function name and the “(” that follows it. See Section 11.3, “Keywords and Reserved Words”.您可以在同一语句中引用不同数据库中的表。You can refer to tables from different databases in the same statement.
安全性Security
非常灵活和安全的权限和密码系统,支持基于主机的验证。A privilege and password system that is very flexible and secure, and that enables host-based verification.
通过在连接到服务器时对所有密码流量进行加密来实现密码安全。Password security by encryption of all password traffic when you connect to a server.
可扩展性和限制Scalability and Limits
支持大型我们使用包含 5000 万条记录的 MySQL Server 的数据库。我们还知道使用包含 200,000 个表和大约 5,000,000,000 行的 MySQL Server 的用户。Support for large databases. We use MySQL Server with databases that contain 50 million records. We also know of users who use MySQL Server with 200,000 tables and about 5,000,000,000 rows.
每个表最多支持 64 个索引。每个索引可以由 1 到 16 列或部分列组成。
InnoDB表的最大索引宽度为 767 字节或 3072 字节。请参阅第 17.21 节“InnoDB 限制”。MyISAM表的最大索引宽度为 1000 字节。请参阅第 18.2 节“MyISAM 存储引擎”。索引可以使用列的前缀CHAR、VARCHAR、BLOB或TEXT列类型。Support for up to 64 indexes per table. Each index may consist of 1 to 16 columns or parts of columns. The maximum index width forInnoDBtables is either 767 bytes or 3072 bytes. See Section 17.21, “InnoDB Limits”. The maximum index width forMyISAMtables is 1000 bytes. See Section 18.2, “The MyISAM Storage Engine”. An index may use a prefix of a column forCHAR,VARCHAR,BLOB, orTEXTcolumn types.
连接Connectivity
客户端可以连接到 MySQL 使用多种协议的服务器:Clients can connect to MySQL Server using several protocols:
客户端可以在任何平台上使用 TCP/IP 套接字进行连接。Clients can connect using TCP/IP sockets on any platform.
在 Windows 系统上,如果服务器启动时启用了
named_pipe系统变量,则客户端可以使用命名管道进行连接。如果在启用shared_memory系统变量的情况下启动,Windows 服务器也支持共享内存连接。客户端可以使用--protocol=memory选项通过共享内存进行连接。On Windows systems, clients can connect using named pipes if the server is started with thenamed_pipesystem variable enabled. Windows servers also support shared-memory connections if started with theshared_memorysystem variable enabled. Clients can connect through shared memory by using the--protocol=memoryoption.在 Unix 系统上,客户端可以使用 Unix 域套接字文件进行连接。On Unix systems, clients can connect using Unix domain socket files.
MySQL 客户端程序可以用多种语言编写。用 C 编写的客户端库适用于用 C 或 C++ 编写的客户端,或者任何提供 C 绑定的语言。MySQL client programs can be written in many languages. A client library written in C is available for clients written in C or C++, or for any language that provides C bindings.
C、C++、Eiffel、Java、Perl、PHP、Python、Ruby 和 Tcl 的 API 可用,使 MySQL 客户端能够用多种语言编写。请参阅第 31 章,连接器和 API。APIs for C, C++, Eiffel, Java, Perl, PHP, Python, Ruby, and Tcl are available, enabling MySQL clients to be written in many languages. See Chapter 31, Connectors and APIs.
Connector/ODBC (MyODBC) 接口为使用 ODBC(开放数据库连接)连接的客户端程序提供 MySQL 支持。例如,您可以使用 MS Access 连接到 MySQL 服务器。客户端可以在 Windows 或 Unix 上运行。连接器/ODBC 源可用。支持所有 ODBC 2.5 函数以及许多其他函数。请参阅 MySQL Connector/ODBC 开发人员指南。The Connector/ODBC (MyODBC) interface provides MySQL support for client programs that use ODBC (Open Database Connectivity) connections. For example, you can use MS Access to connect to your MySQL server. Clients can be run on Windows or Unix. Connector/ODBC source is available. All ODBC 2.5 functions are supported, as are many others. See MySQL Connector/ODBC Developer Guide.
Connector/J 接口为使用 JDBC 连接的 Java 客户端程序提供 MySQL 支持。客户端可以在 Windows 或 Unix 上运行。连接器/J 源可用。请参阅 MySQL Connector/J 开发人员指南。The Connector/J interface provides MySQL support for Java client programs that use JDBC connections. Clients can be run on Windows or Unix. Connector/J source is available. See MySQL Connector/J Developer Guide.
MySQL Connector/NET 使开发人员能够轻松创建需要与 MySQL 进行安全、高性能数据连接的 .NET 应用程序。它实现所需的 ADO.NET 接口并集成到 ADO.NET 感知工具中。开发人员可以使用他们选择的 .NET 语言构建应用程序。 MySQL Connector/NET 是一个完全托管的 ADO.NET 驱动程序,用 100% 纯 C# 编写。请参阅 MySQL Connector/NET 开发人员指南。MySQL Connector/NET enables developers to easily create .NET applications that require secure, high-performance data connectivity with MySQL. It implements the required ADO.NET interfaces and integrates into ADO.NET aware tools. Developers can build applications using their choice of .NET languages. MySQL Connector/NET is a fully managed ADO.NET driver written in 100% pure C#. See MySQL Connector/NET Developer Guide.
本地化Localization
服务器可以以多种语言向客户端提供错误消息。请参阅第 12.12 节“设置错误消息语言”。The server can provide error messages to clients in many languages. See Section 12.12, “Setting the Error Message Language”.
完全支持多种不同的字符集,包括
latin1(cp1252)、german、big5、ujis、多种 Unicode 字符集等等。例如,斯堪的纳维亚字符 “å”、“ä” 和 “ö” 允许出现在表名和列名中。Full support for several different character sets, includinglatin1(cp1252),german,big5,ujis, several Unicode character sets, and more. For example, the Scandinavian characters “å”, “ä” and “ö” are permitted in table and column names.所有数据都以所选字符集保存。All data is saved in the chosen character set.
根据默认字符集和排序规则进行排序和比较。启动 MySQL 服务器时可以更改此设置(请参阅第 12.3.2 节“服务器字符集和排序规则”)。要查看非常高级的排序示例,请查看捷克语排序代码。 MySQL 服务器支持多种不同的字符集,可以在编译时和运行时指定。Sorting and comparisons are done according to the default character set and collation. It is possible to change this when the MySQL server is started (see Section 12.3.2, “Server Character Set and Collation”). To see an example of very advanced sorting, look at the Czech sorting code. MySQL Server supports many different character sets that can be specified at compile time and runtime.
服务器时区可以动态更改,各个客户端可以指定自己的时区。请参阅第 7.1.15 节“MySQL 服务器时区支持”。The server time zone can be changed dynamically, and individual clients can specify their own time zone. See Section 7.1.15, “MySQL Server Time Zone Support”.
客户端和工具Clients and Tools
MySQL 包含多个客户端和实用程序。其中包括命令行程序,例如 mysqldump 和 mysqladmin,以及图形化程序,例如MySQL Workbench。MySQL includes several client and utility programs. These include both command-line programs such as mysqldump and mysqladmin, and graphical programs such as MySQL Workbench.
MySQL Server 内置支持 SQL 语句来检查、优化和修复表。这些语句可以通过 mysqlcheck 客户端从命令行获得。 MySQL 还包括 myisamchk,这是一个非常快速的命令行实用程序,用于在
MyISAM表上执行这些操作。请参阅第 6 章,MySQL 程序。MySQL Server has built-in support for SQL statements to check, optimize, and repair tables. These statements are available from the command line through the mysqlcheck client. MySQL also includes myisamchk, a very fast command-line utility for performing these operations onMyISAMtables. See Chapter 6, MySQL Programs.可以使用
--help或-?选项调用 MySQL 程序以获得在线帮助。MySQL programs can be invoked with the--helpor-?option to obtain online assistance.