1. 程式人生 > >mysql檢視是否支援分割槽以及檢視具體某一表的詳細分割槽資訊情況

mysql檢視是否支援分割槽以及檢視具體某一表的詳細分割槽資訊情況

檢視是否支援分割槽:

mysql> show variables like '%partition%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| have_partitioning | YES   |
+-------------------+-------+
1 row in set (0.00 sec)

可以查看錶是否為分割槽表
show table status like 'table_name';
例如:
mysql> show table status like '%terminal_alarm_list_bak%'\G;
*************************** 1. row ***************************
           Name: terminal_alarm_list_bak
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 34219
 Avg_row_length: 401
    Data_length: 13729792
Max_data_length: 0
   Index_length: 4423680
      Data_free: 26214400
 Auto_increment: 113299
    Create_time: NULL
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options: partitioned         Comment: 1 row in set (0.38 sec)
如果要檢視分割槽的資訊,可以通過sql語句來查詢:
 select * from information_schema.partitions where table_schema=schema() and table_name = '表名';
mysql> select * from information_schema.partitions where table_schema=schema() and table_name = 'terminal_alarm_list_bak'\G;
*************************** 1. row ***************************
                                TABLE_CATALOG: NULL
                                  TABLE_SCHEMA: cpc
                                      TABLE_NAME: terminal_alarm_list_bak
                               PARTITION_NAME: p20131031
                        SUBPARTITION_NAME: NULL
       PARTITION_ORDINAL_POSITION: 1
SUBPARTITION_ORDINAL_POSITION: NULL
                         PARTITION_METHOD: RANGE
                  SUBPARTITION_METHOD: NULL
                  PARTITION_EXPRESSION: TO_DAYS (createtime)
           SUBPARTITION_EXPRESSION: NULL
                PARTITION_DESCRIPTION: 735537
                                   TABLE_ROWS: 3921
                         AVG_ROW_LENGTH: 405
                                 DATA_LENGTH: 1589248
                        MAX_DATA_LENGTH: NULL
                                INDEX_LENGTH: 344064
                                     DATA_FREE: 5242880
                                 CREATE_TIME: NULL
                                 UPDATE_TIME: NULL
                                   CHECK_TIME: NULL
                                      CHECKSUM: NULL
                    PARTITION_COMMENT:
                                   NODEGROUP: default
                       TABLESPACE_NAME: NULL