10bet网址
米ySQL Information Schema
Related Documentation Download this Excerpt

米ySQL Information Schema/INFORMATION_SCHEMA General Tables/ The INFORMATION_SCHEMA PARTITIONS Table

4.21 The INFORMATION_SCHEMA PARTITIONS Table

ThePARTITIONStable 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, seePartitioning.

ThePARTITIONStable has these columns:

  • TABLE_CATALOG

    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_NAME

    The name of the table containing the partition.

  • PARTITION_NAME

    The name of the partition.

  • SUBPARTITION_NAME

    If thePARTITIONStable row represents a subpartition, the name of subpartition; otherwiseNULL.

    ForNDB: This value is alwaysNULL.

  • PARTITION_ORDINAL_POSITION

    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

    One of the valuesRANGE,LIST,HASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available partitioning types as discussed inPartitioning Types.

  • SUBPARTITION_METHOD

    One of the valuesHASH,LINEAR HASH,KEY, orLINEAR KEY; that is, one of the available subpartitioning types as discussed inSubpartitioning.

  • PARTITION_EXPRESSION

    The expression for the partitioning function used in theCREATE TABLEorALTER TABLEstatement that created the table's current partitioning scheme.

    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;

    ThePARTITION_EXPRESSIONcolumn in aPARTITIONStable row for a partition from this table displaysc1 + 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 | +----------------------+
  • SUBPARTITION_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.

    If the table has no subpartitions, this column isNULL.

  • PARTITION_DESCRIPTION

    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 or米AXVALUE. For aLISTpartition, this column contains the values defined in the partition'sVALUES INclause, which is a list of comma-separated integer values.

    For partitions whosePARTITION_METHODis other thanRANGEorLIST, this column is alwaysNULL.

  • TABLE_ROWS

    The number of table rows in the partition.

    For partitionedInnoDBtables, the row count given in theTABLE_ROWScolumn is only an estimated value used in SQL optimization, and may not always be exact.

    ForNDBtables, you can also obtain this information using thendb_descutility.

  • AVG_ROW_LENGTH

    The average length of the rows stored in this partition or subpartition, in bytes. This is the same asDATA_LENGTHdivided byTABLE_ROWS.

    ForNDBtables, you can also obtain this information using thendb_descutility.

  • 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.

    ForNDBtables, you can also obtain this information using thendb_descutility.

  • 米AX_DATA_LENGTH

    The maximum number of bytes that can be stored in this partition or subpartition.

    ForNDBtables, you can also obtain this information using thendb_descutility.

  • INDEX_LENGTH

    The length of the index file for this partition or subpartition, in bytes.

    For partitions ofNDBtables, whether the tables use implicit or explicit partitioning, theINDEX_LENGTHcolumn value is always 0. However, you can obtain equivalent information using thendb_descutility.

  • DATA_FREE

    The number of bytes allocated to the partition or subpartition but not used.

    ForNDBtables, you can also obtain this information using thendb_descutility.

  • 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.

    For partitionedInnoDBtables, the value is alwaysNULL.

  • 校验和

    The checksum value, if any; otherwiseNULL.

  • PARTITION_COMMENT

    The text of the comment, if the partition has one. If not, this value is empty.

    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.

  • NODEGROUP

    This is the nodegroup to which the partition belongs. This is relevant only to NDB Cluster tables; otherwise, the value is always0.

  • TABLESPACE_NAME

    The name of the tablespace to which the partition belongs. The value is alwaysDEFAULT, unless the table uses theNDBstorage engine (see theNotesat the end of this section).

Notes

  • PARTITIONSis a nonstandardINFORMATION_SCHEMAtable.

  • 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.

  • AnNDBtable which is not explicitly partitioned has one row in thePARTITIONStable for each data node in the NDB cluster. For each such row:

    • TheSUBPARTITION_NAME,SUBPARTITION_ORDINAL_POSITION,SUBPARTITION_METHOD,PARTITION_EXPRESSION,SUBPARTITION_EXPRESSION,CREATE_TIME,UPDATE_TIME,CHECK_TIME,校验和, andTABLESPACE_NAMEcolumns are allNULL.

    • ThePARTITION_METHODis alwaysAUTO.

    • TheNODEGROUPcolumn isdefault.

    • ThePARTITION_EXPRESSIONandPARTITION_COMMENTcolumns are empty.