mysql分區

RANGE 分區

LIST 分區

HASH分區

Key分區

REATE TABLE `test` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增ID',
  `name` int(11) unsigned zerofill NOT NULL COMMENT '測試名稱',
  `password` varchar(255) NOT NULL DEFAULT '' COMMENT '密碼',
  `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加時間',
  `update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新時間',
  PRIMARY KEY (`id`,`name`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3535629 DEFAULT CHARSET=utf8
/*!50100 PARTITION BY RANGE (`name`)
(PARTITION p0 VALUES LESS THAN (1000000) ENGINE = InnoDB,
 PARTITION p1 VALUES LESS THAN (2000000) ENGINE = InnoDB,
 PARTITION p2 VALUES LESS THAN (3000000) ENGINE = InnoDB,
  PARTITION p4 VALUES LESS THAN MAXVALUE   ENGINE = InnoDB) */;
ALTER TABLE test PARTITION by RANGE(`name`)
(
		partition p0 VALUES LESS THAN (1000000),
    partition p1 VALUES LESS THAN (2000000),
    partition p2 VALUES LESS THAN (3000000),
   PARTITION p4 VALUES LESS THAN MAXVALUE  
);

###刪除:注意drop會刪除數據測試

刪除test表的分區並將其恢復爲其原始的非分區狀態。
alter table test remove partitioning;

查看

explain partitions select * from test\G
相關文章
相關標籤/搜索