在 MySQL 8.4 中,分区支持实际上不是由 MySQL 服务器提供的,而是由表存储引擎自身的或原生的分区处理器提供的。在 MySQL 8.4 中,只有 InnoDB 和 NDB 存储引擎提供原生分区处理器。这意味着使用这些存储引擎之外的任何存储引擎都无法创建分区表。(你必须使用 MySQL NDB Cluster 和 NDB 存储引擎来创建 NDB 表。)In MySQL 8.4, partitioning support is not actually
provided by the MySQL Server, but rather by a table storage
engine's own or native partitioning handler. In MySQL
8.4, only the InnoDB
and NDB storage engines provide
native partitioning handlers. This means that partitioned tables
cannot be created using any other storage engine than these.
(You must be using MySQL NDB Cluster with the
NDB storage engine to create
NDB tables.)
InnoDB 存储引擎。 InnoDB 外键和 MySQL 分区不兼容。分区的 InnoDB 表不能有外键引用,也不能有被外键引用的列。有外键或被外键引用的 InnoDB 表不能进行分区。InnoDB storage engine.
InnoDB foreign keys and MySQL
partitioning are not compatible. Partitioned
InnoDB tables cannot have foreign key
references, nor can they have columns referenced by foreign
keys. InnoDB tables which have or which are
referenced by foreign keys cannot be partitioned.
ALTER
TABLE ... OPTIMIZE PARTITION 对使用 InnoDB 的分区表不能正常工作。对于此类表,请改用 ALTER TABLE ... REBUILD PARTITION 和 ALTER TABLE ... ANALYZE PARTITION。有关更多信息,请参阅 第 15.1.9.1 节,“ALTER TABLE 分区操作”。ALTER
TABLE ... OPTIMIZE PARTITION does not work correctly
with partitioned tables that use InnoDB. Use
ALTER TABLE ... REBUILD PARTITION and
ALTER TABLE ... ANALYZE PARTITION, instead,
for such tables. For more information, see
Section 15.1.9.1, “ALTER TABLE Partition Operations”.
用户定义的分区与 NDB 存储引擎(NDB 集群)。 对 KEY(包括 LINEAR KEY)的分区是 NDB 存储引擎支持的唯一分区类型。在 NDB 集群中,通常情况下无法使用除 [LINEAR] KEY 之外的任何分区类型创建 NDB 集群表,尝试这样做会导致错误。User-defined partitioning and the NDB storage engine (NDB Cluster).
Partitioning by KEY (including
LINEAR KEY) is the only type of
partitioning supported for the
NDB storage engine. It is not
possible under normal circumstances in NDB Cluster to create
an NDB Cluster table using any partitioning type other than
[LINEAR] KEY, and
attempting to do so fails with an error.
为一个 NDB 表定义的分区的最大数量取决于集群中的数据节点和节点组的数量、所使用的 NDB Cluster 软件版本以及其他因素。更多信息请参见 NDB 和用户定义的分区。The maximum number of partitions that can be defined for an
NDB table depends on the number of
data nodes and node groups in the cluster, the version of the
NDB Cluster software in use, and other factors. See
NDB and user-defined partitioning,
for more information.
The maximum amount of fixed-size data that can be stored per
partition in an NDB table is 128 TB.
Previously, this was 16 GB.
CREATE TABLE 和 ALTER
TABLE 语句如果导致用户分区的 NDB 表不满足以下一项或两项要求,将不被允许,并会报错:CREATE TABLE and
ALTER
TABLE statements that would cause a user-partitioned
NDB table not to meet either or
both of the following two requirements are not permitted, and
fail with an error:
表必须有显式主键。The table must have an explicit primary key.
表的分区表达式中列出的所有列必须是主键的一部分。All columns listed in the table's partitioning expression must be part of the primary key.
例外。 如果使用空列列表(即使用 PARTITION BY KEY() 或 NDB)创建用户分区的 PARTITION BY
LINEAR KEY() 表,则不需要显式主键。Exception.
If a user-partitioned NDB table
is created using an empty column-list (that is, using
PARTITION BY KEY() or PARTITION BY
LINEAR KEY()), then no explicit primary key is
required.
分区选择。 NDB 表不支持分区选择。更多信息参见 第 26.5 节,“分区选择”。Partition selection.
Partition selection is not supported for
NDB tables. See
Section 26.5, “Partition Selection”, for more
information.
升级分区表。 在执行升级时,按 KEY 分区的表必须先导出再重新导入。Upgrading partitioned tables.
When performing an upgrade, tables which are partitioned by
KEY must be dumped and reloaded.
有关将MyISAM表转换为InnoDB的信息,请参见第 17.6.1.5 节,“将表从 MyISAM 转换为 InnoDB”。For information about converting MyISAM
tables to InnoDB, see
Section 17.6.1.5, “Converting Tables from MyISAM to InnoDB”.