文档首页
MySQL 8.4 参考手册
8.4 中文镜像

MySQL 8.4 参考手册 · 中文镜像

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

打开官方英文原文 ↗

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

中文点击中文段落可显示 / 隐藏英文原文本页译文覆盖 71%

28.3.21 INFORMATION_SCHEMA PARTITIONS 表28.3.21 The INFORMATION_SCHEMA PARTITIONS Table

PARTITIONS 表提供有关表分区的信息。该表中的每一行对应于分区表的单个分区或子分区。有关表分区的更多信息,请参见 第 26 章,分区。The PARTITIONS table provides information about table partitions. Each row in this table corresponds to an individual partition or subpartition of a partitioned table. For more information about partitioning tables, see Chapter 26, Partitioning.

PARTITIONS 表包含以下列:The PARTITIONS table has these columns:

  • TABLE_CATALOG

    表所属的目录名称。该值始终为 def。The name of the catalog to which the table belongs. This value is always def.

  • TABLE_SCHEMA

    表所属的模式(数据库)名称。The name of the schema (database) to which the table belongs.

  • TABLE_NAMETABLE_NAME

    包含该分区的表的名称。The name of the table containing the partition.

  • PARTITION_NAME

    分区的名称。The name of the partition.

  • SUBPARTITION_NAME

    如果 PARTITIONS 表行表示一个子分区,则为子分区的名称;否则为 NULL。If the PARTITIONS table row represents a subpartition, the name of subpartition; otherwise NULL.

    对于 NDB:此值始终为 NULL。For NDB: This value is always NULL.

  • PARTITION_ORDINAL_POSITION

    所有分区按照定义的顺序进行索引,其中 1 是分配给第一个分区的编号。随着分区的增加、删除和重组,索引可能会发生变化;本列显示的数字反映了当前顺序,同时考虑了任何索引更改。All partitions are indexed in the same order as they are defined, with 1 being the number assigned to the first partition. The indexing can change as partitions are added, dropped, and reorganized; the number shown is this column reflects the current order, taking into account any indexing changes.

  • SUBPARTITION_ORDINAL_POSITION

    给定分区内的子分区也按照与表内分区索引相同的方式进行索引和重新索引。Subpartitions within a given partition are also indexed and reindexed in the same manner as partitions are indexed within a table.

  • PARTITION_METHOD

    值之一 RANGE、LIST、HASH、LINEAR HASH、KEY 或 LINEAR KEY;即 第 26.2 节,“分区类型” 讨论的可用分区类型之一。One of the values RANGE, LIST, HASH, LINEAR HASH, KEY, or LINEAR KEY; that is, one of the available partitioning types as discussed in Section 26.2, “Partitioning Types”.

  • SUBPARTITION_METHOD

    值之一 HASH、LINEAR HASH、KEY 或 LINEAR KEY;即 第 26.2.6 节,“子分区” 讨论的可用子分区类型之一。One of the values HASH, LINEAR HASH, KEY, or LINEAR KEY; that is, one of the available subpartitioning types as discussed in Section 26.2.6, “Subpartitioning”.

  • PARTITION_EXPRESSION

    用于 CREATE TABLE 或 ALTER TABLE 语句的分区函数表达式,这些语句用于创建表当前的分区方案。The expression for the partitioning function used in the CREATE TABLE or ALTER TABLE statement that created the table's current partitioning scheme.

    例如,考虑在 test 数据库中使用以下语句创建的分区表:For example, consider a partitioned table created in the test database using this statement:

    CREATE TABLE tp (
        c1 INT,
        c2 INT,
        c3 VARCHAR(25)
    )
    PARTITION BY HASH(c1 + c2)
    PARTITIONS 4;
    

    来自此表的分区在 PARTITIONS 表中的 PARTITION_EXPRESSION 列显示 c1 + c2,如下所示:The PARTITION_EXPRESSION column in a PARTITIONS table row for a partition from this table displays c1 + c2, as shown here:

    mysql> SELECT DISTINCT PARTITION_EXPRESSION
           FROM INFORMATION_SCHEMA.PARTITIONS
           WHERE TABLE_NAME='tp' AND TABLE_SCHEMA='test';
    +----------------------+
    | PARTITION_EXPRESSION |
    +----------------------+
    | c1 + c2              |
    +----------------------+
    

    对于未明确分区的表,该列始终为 NULL,无论存储引擎如何。For a table that is not explicitly partitioned, this column is always NULL, regardless of storage engine.

  • SUBPARTITION_EXPRESSION

    这在子分区表达式中也是同样的作用,子分区表达式定义表的子分区,就像 PARTITION_EXPRESSION 定义表的分区表达式一样。This works in the same fashion for the subpartitioning expression that defines the subpartitioning for a table as PARTITION_EXPRESSION does for the partitioning expression used to define a table's partitioning.

    如果表没有子分区,则该列为 NULL。If the table has no subpartitions, this column is NULL.

  • PARTITION_DESCRIPTION

    此列用于 RANGE 和 LIST 分区。对于 RANGE 分区,它包含设置在分区的 VALUES LESS THAN 子句中的值,该值可以是整数或 MAXVALUE。对于 LIST 分区,此列包含在分区的 VALUES IN 子句中定义的值,这是一个以逗号分隔的整数值列表。This column is used for RANGE and LIST partitions. For a RANGE partition, it contains the value set in the partition's VALUES LESS THAN clause, which can be either an integer or MAXVALUE. For a LIST partition, this column contains the values defined in the partition's VALUES IN clause, which is a list of comma-separated integer values.

    对于 PARTITION_METHOD 非 RANGE 或 LIST 的分区,此列始终为 NULL。For partitions whose PARTITION_METHOD is other than RANGE or LIST, this column is always NULL.

  • TABLE_ROWS

    分区中的表行数。The number of table rows in the partition.

    对于分区的 InnoDB 表,TABLE_ROWS 列中给出的行数只是用于 SQL 优化的估计值,并不总是精确的。For partitioned InnoDB tables, the row count given in the TABLE_ROWS column is only an estimated value used in SQL optimization, and may not always be exact.

    对于 NDB 表,你也可以使用 ndb_desc 工具获取此信息。For NDB tables, you can also obtain this information using the ndb_desc utility.

  • AVG_ROW_LENGTH

    存储在此分区或子分区中的行的平均长度(以字节为单位)。这等于 DATA_LENGTH 除以 TABLE_ROWS。The average length of the rows stored in this partition or subpartition, in bytes. This is the same as DATA_LENGTH divided by TABLE_ROWS.

    对于 NDB 表,你也可以使用 ndb_desc 工具获取此信息。For NDB tables, you can also obtain this information using the ndb_desc utility.

  • DATA_LENGTH

    存储在此分区或子分区中所有行的总长度,以字节为单位;也就是说,存储在该分区或子分区中的字节总数。The total length of all rows stored in this partition or subpartition, in bytes; that is, the total number of bytes stored in the partition or subpartition.

    对于 NDB 表,你也可以使用 ndb_desc 工具获取此信息。For NDB tables, you can also obtain this information using the ndb_desc utility.

  • MAX_DATA_LENGTH

    此分区或子分区中可以存储的最大字节数。The maximum number of bytes that can be stored in this partition or subpartition.

    对于 NDB 表,你也可以使用 ndb_desc 工具获取此信息。For NDB tables, you can also obtain this information using the ndb_desc utility.

  • INDEX_LENGTH

    此分区或子分区的索引文件长度,以字节为单位。The length of the index file for this partition or subpartition, in bytes.

    对于NDB 表的分区,无论表使用隐式还是显式分区,INDEX_LENGTH 列的值始终为 0。然而,你可以使用ndb_desc 工具获取等效的信息。For partitions of NDB tables, whether the tables use implicit or explicit partitioning, the INDEX_LENGTH column value is always 0. However, you can obtain equivalent information using the ndb_desc utility.

  • DATA_FREE

    分配给分区或子分区但未使用的字节数。The number of bytes allocated to the partition or subpartition but not used.

    对于 NDB 表,你也可以使用 ndb_desc 工具获取此信息。For NDB tables, you can also obtain this information using the ndb_desc utility.

  • CREATE_TIME

    分区或子分区创建的时间。The time that the partition or subpartition was created.

  • UPDATE_TIME

    分区或子分区最后修改的时间。The time that the partition or subpartition was last modified.

  • CHECK_TIME

    该分区或子分区所属表的最后检查时间。The last time that the table to which this partition or subpartition belongs was checked.

    对于分区的 InnoDB 表,该值始终为 NULL。For partitioned InnoDB tables, the value is always NULL.

  • CHECKSUMCHECKSUM

    校验和的值(如果有);否则为 NULL。The checksum value, if any; otherwise NULL.

  • PARTITION_COMMENT

    分区的注释文本,如果存在分区注释。如果没有,则该值为空。The text of the comment, if the partition has one. If not, this value is empty.

    分区注释的最大长度定义为 1024 个字符,并且 PARTITION_COMMENT 列的显示宽度也是 1024 个字符,以匹配此限制。The maximum length for a partition comment is defined as 1024 characters, and the display width of the PARTITION_COMMENT column is also 1024, characters to match this limit.

  • NODEGROUPNODEGROUP

    这是分区所属的节点组。对于 NDB 集群表,这个值始终为 default。对于使用 NDB 以外存储引擎的分区表,该值也为 default。否则,此列为空。This is the nodegroup to which the partition belongs. For NDB Cluster tables, this is always default. For partitioned tables using storage engines other than NDB, the value is also default. Otherwise, this column is empty.

  • TABLESPACE_NAME

    分区所属表空间的名称。除非表使用 NDB 存储引擎(参见本节末尾的 备注),该值始终为 DEFAULT。The name of the tablespace to which the partition belongs. The value is always DEFAULT, unless the table uses the NDB storage engine (see the Notes at the end of this section).

备注Notes

  • PARTITIONS 是非标准的 INFORMATION_SCHEMA 表。PARTITIONS is a nonstandard INFORMATION_SCHEMA table.

  • 使用除 NDB 之外的任何存储引擎且未分区的表,在 PARTITIONS 表中有一行。然而,PARTITION_NAME、SUBPARTITION_NAME、PARTITION_ORDINAL_POSITION、SUBPARTITION_ORDINAL_POSITION、PARTITION_METHOD、SUBPARTITION_METHOD、PARTITION_EXPRESSION、SUBPARTITION_EXPRESSION 和 PARTITION_DESCRIPTION 列的值均为 NULL。此外,此情况下的 PARTITION_COMMENT 列为空白。A table using any storage engine other than NDB and which is not partitioned has one row in the PARTITIONS table. However, the values of the PARTITION_NAME, SUBPARTITION_NAME, PARTITION_ORDINAL_POSITION, SUBPARTITION_ORDINAL_POSITION, PARTITION_METHOD, SUBPARTITION_METHOD, PARTITION_EXPRESSION, SUBPARTITION_EXPRESSION, and PARTITION_DESCRIPTION columns are all NULL. Also, the PARTITION_COMMENT column in this case is blank.

  • 一个未显式分区的 NDB 表在 PARTITIONS 表中,对于 NDB 集群中的每个数据节点都有一行。对于每一行:An NDB table which is not explicitly partitioned has one row in the PARTITIONS table for each data node in the NDB cluster. For each such row:

    • SUBPARTITION_NAME、SUBPARTITION_ORDINAL_POSITION、SUBPARTITION_METHOD、PARTITION_EXPRESSION、SUBPARTITION_EXPRESSION、CREATE_TIME、UPDATE_TIME、CHECK_TIME、CHECKSUM 和 TABLESPACE_NAME 列都是 NULL。The SUBPARTITION_NAME, SUBPARTITION_ORDINAL_POSITION, SUBPARTITION_METHOD, PARTITION_EXPRESSION, SUBPARTITION_EXPRESSION, CREATE_TIME, UPDATE_TIME, CHECK_TIME, CHECKSUM, and TABLESPACE_NAME columns are all NULL.

    • PARTITION_METHOD 始终为 AUTO。The PARTITION_METHOD is always AUTO.

    • NODEGROUP 列为 default。The NODEGROUP column is default.

    • PARTITION_COMMENT 列为空。The PARTITION_COMMENT column is empty.