Overview
The information_schema.PARTITIONS view is used to display partition information.
Columns
Field |
Type |
Nullable |
Description |
|---|---|---|---|
| TABLE_CATALOG | text | NO | Fixed value (def). |
| TABLE_SCHEMA | varchar(128) | NO | The name of the database. |
| TABLE_NAME | varchar(256) | NO | Table name. |
| PARTITION_NAME | varchar(64) | NO | Partition name. |
| SUBPARTITION_NAME | varchar(64) | NO | Subpartition name. |
| PARTITION_ORDINAL_POSITION | bigint(20) unsigned | NO | The position of the current partition among all partitions. |
| SUBPARTITION_ORDINAL_POSITION | bigint(20) unsigned | NO | The position of the current subpartition among all subpartitions. |
| PARTITION_METHOD | varchar(13) | NO | Partition type. |
| SUBPARTITION_METHOD | varchar(13) | NO | Subpartition type. |
| PARTITION_EXPRESSION | text | NO | Partition function expression. |
| SUBPARTITION_EXPRESSION | text | NO | Subpartition function expression. |
| PARTITION_DESCRIPTION | text | NO | Applicable to descriptions of RANGE and LIST partitions. |
| SUBPARTITION_DESCRIPTION | text | NO | Applicable to descriptions of RANGE and LIST subpartitions. |
| TABLE_ROWS | bigint(20) unsigned | NO | The number of rows in the partition. |
| AVG_ROW_LENGTH | bigint(21) unsigned | NO | The average length of a row stored in a partition or subpartition. |
| DATA_LENGTH | bigint(0) unsigned | NO | The total number of bytes stored in a partition or subpartition, that is, the storage space occupied by a table partition or subpartition, calculated in macroblocks, with the unit being bytes. |
| MAX_DATA_LENGTH | bigint(0) unsigned | NO | This field is not currently supported and defaults to 0. |
| INDEX_LENGTH | bigint(0) unsigned | NO | Total index length, which is the storage space occupied by the indexes of a table partition or subpartition. It is calculated in macroblocks and the unit is bytes. |
| DATA_FREE | bigint(0) unsigned | NO | This field is not currently supported and defaults to 0. |
| CREATE_TIME | timestamp(6) | NO | The partition creation time. |
| UPDATE_TIME | datetime | NO | This field is not currently supported and defaults to NULL. |
| CHECK_TIME | datetime | YES | This field is not currently supported and defaults to NULL. |
| CHECKSUM | bigint(0) | NO | This field is not currently supported and defaults to NULL. |
| PARTITION_COMMENT | text | NO | Partition comment. |
| NODEGROUP | varchar(256) | NO | The node group to which the partition belongs. |
| TABLESPACE_NAME | varchar(268) | NO | The name of the tablespaces to which the partition belongs. |
Sample query
Query the partition information in table t1.
obclient> select * from information_schema.partitions where table_name = 't1' limit 1\G
The query result is as follows:
*************************** 1. row ***************************
TABLE_CATALOG: def
TABLE_SCHEMA: test
TABLE_NAME: t1
PARTITION_NAME: p0
SUBPARTITION_NAME: NULL
PARTITION_ORDINAL_POSITION: 1
SUBPARTITION_ORDINAL_POSITION: NULL
PARTITION_METHOD: HASH
SUBPARTITION_METHOD: NULL
PARTITION_EXPRESSION: a
SUBPARTITION_EXPRESSION: NULL
PARTITION_DESCRIPTION: NULL
SUBPARTITION_DESCRIPTION: NULL
TABLE_ROWS: 3000
AVG_ROW_LENGTH: 37
DATA_LENGTH: 0
MAX_DATA_LENGTH: NULL
INDEX_LENGTH: 0
DATA_FREE: NULL
CREATE_TIME: 2024-12-17 10:56:36.834215
UPDATE_TIME: NULL
CHECK_TIME: NULL
CHECKSUM: NULL
PARTITION_COMMENT:
NODEGROUP: default
TABLESPACE_NAME: NULL
1 row in set (0.020 sec)