MySQL partition table

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

MySQL partition table

文章 yehlu »

create

代碼: 選擇全部

 SHOW CREATE TABLE sell_pp;

代碼: 選擇全部

 CREATE TABLE `sell_pp` (
  `sell_id` int(11) unsigned zerofill NOT NULL,
  `date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '交易日期',
  PRIMARY KEY (`sell_id`,`date`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
/*!50100 PARTITION BY RANGE (year(date))
(PARTITION p0 VALUES LESS THAN (2005) ENGINE = MyISAM,
 PARTITION p1 VALUES LESS THAN (2010) ENGINE = MyISAM,
 PARTITION p2 VALUES LESS THAN (2015) ENGINE = MyISAM,
 PARTITION p3 VALUES LESS THAN (2020) ENGINE = MyISAM,
 PARTITION p4 VALUES LESS THAN (2025) ENGINE = MyISAM,
 PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ |
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: MySQL partition table

文章 yehlu »

代碼: 選擇全部

use information_schema
select table_name, partition_name, table_rows from partitions where table_name = 'sell_pp' and partition_name is not null;
+------------+----------------+------------+
| table_name | partition_name | table_rows |
+------------+----------------+------------+
| sell_pp    | p0             |          0 |
| sell_pp    | p1             |          0 |
| sell_pp    | p2             |          0 |
| sell_pp    | p3             |          0 |
| sell_pp    | p4             |          0 |
| sell_pp    | p5             |          0 |
| sell_pp    | p0             |     109371 |
| sell_pp    | p1             |     834244 |
| sell_pp    | p2             |    1632618 |
| sell_pp    | p3             |      39046 |
| sell_pp    | p4             |          0 |
| sell_pp    | p5             |          0 |
+------------+----------------+------------+
12 rows in set (0.01 sec)

回覆文章

回到「MySQL」