MYSQL创建或增加分区

在创建表时创建分区

CREATE TABLE `ts_rta_visit_from` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `STAT_DATE` varchar(8) NOT NULL COMMENT '统计日期(日期:YYYYMMDD)',
  `STAT_MINUTE` varchar(4) DEFAULT NULL COMMENT '统计分钟(分钟:HHMM)(每5分钟一个取值,一天共288个取值,从0000-2355)',
  `SITE_ID` varchar(2) DEFAULT NULL COMMENT '站点',
  `TERMINAL_TYPE_ID` varchar(1) DEFAULT '1' COMMENT '终端类型编码',
  `NEW_OLD_UV_FLAG` varchar(1) DEFAULT NULL COMMENT '新老访客标识',
  `VISIT_FROM_ID` varchar(2) DEFAULT NULL COMMENT '访问来源编码',
  `VISIT_FROM_CLASS_ID` varchar(1) DEFAULT NULL COMMENT '访问来源大类编码',
  `COMPARE_PERIOD_ID` varchar(2) DEFAULT NULL COMMENT '对比时间段编码',
  `CD_PV_NUM` int(11) DEFAULT NULL COMMENT '当天累计浏览量',
  `CD_UV_NUM` int(11) DEFAULT NULL COMMENT '当天累计访客数',
  `CD_VISIT_NUM` int(11) DEFAULT NULL COMMENT '当天累计访问次数',
  `CD_VISIT_DURATION` bigint(20) DEFAULT NULL COMMENT '当天累计访问时长',
  `CD_URL_NUM` int(11) DEFAULT NULL COMMENT '当天累计页面数',
  `DATA_TIME` varchar(8) DEFAULT NULL COMMENT '数据处理时间',
  PRIMARY KEY (`ID`,`STAT_DATE`)
) ENGINE=InnoDB AUTO_INCREMENT=4177 DEFAULT CHARSET=utf8 COMMENT='应用层_实时分析_流量来源分析\n\n两份数据:一份到流量来源小类,一份到流量来源大类'
/*!50500 PARTITION BY LIST  COLUMNS(STAT_DATE)
(PARTITION p20151010 VALUES IN ('20151010') ENGINE = InnoDB,
 PARTITION p20151011 VALUES IN ('20151011') ENGINE = InnoDB,
 PARTITION p20151203 VALUES IN ('20151203') ENGINE = InnoDB,
 PARTITION p20151204 VALUES IN ('20151204') ENGINE = InnoDB,
 PARTITION p20151205 VALUES IN ('20151205') ENGINE = InnoDB,
 PARTITION p20151206 VALUES IN ('20151206') ENGINE = InnoDB,
 PARTITION p20151207 VALUES IN ('20151207') ENGINE = InnoDB,
 PARTITION p20151208 VALUES IN ('20151208') ENGINE = InnoDB)

给一张表增加分区

 ALTER TABLE ts_rta_visit_channel ADD PARTITION (PARTITION p20151207 VALUES IN ('20151207') ENGINE = InnoDB);

你可能感兴趣的:(mysql)