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 alwaysdef.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 thePARTITIONStable row represents a subpartition, the name of subpartition; otherwiseNULL.对于
NDB:此值始终为NULL。ForNDB: This value is alwaysNULL.PARTITION_ORDINAL_POSITION所有分区按照定义的顺序进行索引,其中
1是分配给第一个分区的编号。随着分区的增加、删除和重组,索引可能会发生变化;本列显示的数字反映了当前顺序,同时考虑了任何索引更改。All partitions are indexed in the same order as they are defined, with1being 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 valuesRANGE,LIST,HASH,LINEAR HASH,KEY, orLINEAR 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 valuesHASH,LINEAR HASH,KEY, orLINEAR 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 theCREATE TABLEorALTER TABLEstatement that created the table's current partitioning scheme.例如,考虑在
test数据库中使用以下语句创建的分区表:For example, consider a partitioned table created in thetestdatabase 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,如下所示:ThePARTITION_EXPRESSIONcolumn in aPARTITIONStable row for a partition from this table displaysc1 + c2, as shown here:mysql>
SELECT DISTINCT PARTITION_EXPRESSIONFROM INFORMATION_SCHEMA.PARTITIONSWHERE TABLE_NAME='tp' AND TABLE_SCHEMA='test';+----------------------+ | PARTITION_EXPRESSION | +----------------------+ | c1 + c2 | +----------------------+对于未明确分区的表,该列始终为
NULL,无论存储引擎如何。For a table that is not explicitly partitioned, this column is alwaysNULL, 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 asPARTITION_EXPRESSIONdoes for the partitioning expression used to define a table's partitioning.如果表没有子分区,则该列为
NULL。If the table has no subpartitions, this column isNULL.PARTITION_DESCRIPTION此列用于 RANGE 和 LIST 分区。对于
RANGE分区,它包含设置在分区的VALUES LESS THAN子句中的值,该值可以是整数或MAXVALUE。对于LIST分区,此列包含在分区的VALUES IN子句中定义的值,这是一个以逗号分隔的整数值列表。This column is used for RANGE and LIST partitions. For aRANGEpartition, it contains the value set in the partition'sVALUES LESS THANclause, which can be either an integer orMAXVALUE. For aLISTpartition, this column contains the values defined in the partition'sVALUES INclause, which is a list of comma-separated integer values.对于
PARTITION_METHOD非RANGE或LIST的分区,此列始终为NULL。For partitions whosePARTITION_METHODis other thanRANGEorLIST, this column is alwaysNULL.TABLE_ROWS分区中的表行数。The number of table rows in the partition.
对于分区的
InnoDB表,TABLE_ROWS列中给出的行数只是用于 SQL 优化的估计值,并不总是精确的。For partitionedInnoDBtables, the row count given in theTABLE_ROWScolumn is only an estimated value used in SQL optimization, and may not always be exact.对于
NDB表,你也可以使用 ndb_desc 工具获取此信息。ForNDBtables, 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 asDATA_LENGTHdivided byTABLE_ROWS.对于
NDB表,你也可以使用 ndb_desc 工具获取此信息。ForNDBtables, 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 工具获取此信息。ForNDBtables, 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 工具获取此信息。ForNDBtables, 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 ofNDBtables, whether the tables use implicit or explicit partitioning, theINDEX_LENGTHcolumn 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 工具获取此信息。ForNDBtables, 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 partitionedInnoDBtables, the value is alwaysNULL.CHECKSUMCHECKSUM校验和的值(如果有);否则为
NULL。The checksum value, if any; otherwiseNULL.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 thePARTITION_COMMENTcolumn 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 alwaysdefault. For partitioned tables using storage engines other thanNDB, the value is alsodefault. Otherwise, this column is empty.TABLESPACE_NAME分区所属表空间的名称。除非表使用
NDB存储引擎(参见本节末尾的 备注),该值始终为DEFAULT。The name of the tablespace to which the partition belongs. The value is alwaysDEFAULT, unless the table uses theNDBstorage engine (see the Notes at the end of this section).
备注Notes
PARTITIONS是非标准的INFORMATION_SCHEMA表。PARTITIONSis a nonstandardINFORMATION_SCHEMAtable.使用除
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 thanNDBand which is not partitioned has one row in thePARTITIONStable. However, the values of thePARTITION_NAME,SUBPARTITION_NAME,PARTITION_ORDINAL_POSITION,SUBPARTITION_ORDINAL_POSITION,PARTITION_METHOD,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION, andPARTITION_DESCRIPTIONcolumns are allNULL. Also, thePARTITION_COMMENTcolumn in this case is blank.一个未显式分区的
NDB表在PARTITIONS表中,对于 NDB 集群中的每个数据节点都有一行。对于每一行:AnNDBtable which is not explicitly partitioned has one row in thePARTITIONStable 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。TheSUBPARTITION_NAME,SUBPARTITION_ORDINAL_POSITION,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,CREATE_TIME,UPDATE_TIME,CHECK_TIME,CHECKSUM, andTABLESPACE_NAMEcolumns are allNULL.PARTITION_METHOD始终为AUTO。ThePARTITION_METHODis alwaysAUTO.NODEGROUP列为default。TheNODEGROUPcolumn isdefault.PARTITION_COMMENT列为空。ThePARTITION_COMMENTcolumn is empty.