mysql创建按天分区表

下面是按天分区表语句

   CREATE TABLE `rpt_exp_event_bucket_creative_d_across` (
      `bucket_id` VARCHAR(200) NOT NULL DEFAULT 'zhu' COMMENT '分桶id',
      `creative_id` VARCHAR(32)  COMMENT '创意id',
      `creative_name` VARCHAR(32)  COMMENT '创意名称',
      `order_id` VARCHAR(32)  COMMENT '订单id',
      `order_name` VARCHAR(32) COMMENT '订单名称',
      `order_type` VARCHAR(32) COMMENT '订单类型',
      `exp_ectr` bigint(200)  COMMENT 'ectr值',
      `bid_true_cnt` bigint(200)  COMMENT '事件个数',
      `bid_true_ratio` double  COMMENT '事件比例',
      `filter_true_cnt` bigint(200)  COMMENT '事件个数',
      `filter_true_ratio` double  COMMENT '事件比例',
      `filter_false_cnt` bigint(200)  COMMENT '事件个数',
      `filter_false_ratio` double  COMMENT '事件比例',
      `pre_filter_true_cnt` bigint(200)  COMMENT '事件个数',
      `pre_filter_true_ratio` double  COMMENT '事件比例',
      `pre_filter_false_cnt` bigint(200)  COMMENT '事件个数',
      `pre_filter_false_ratio` double  COMMENT '事件比例',
      `exp_filter_true_cnt` bigint(200)  COMMENT '事件个数',
      `exp_filter_true_ratio` double  COMMENT '事件比例',
      `exp_filter_false_cnt` bigint(200)  COMMENT '事件个数',
      `exp_filter_false_ratio` double  COMMENT '事件比例',
      `exp_filter_true_ectr_cnt` bigint(200)  COMMENT '事件个数',
      `exp_filter_true_ectr_ratio` double  COMMENT '事件比例',
      `exp_filter_false_ectr_cnt` bigint(200)  COMMENT '事件个数',
      `exp_filter_false_ectr_ratio` double  COMMENT '事件比例',
      `exp_filter_true_ocpm_cnt` bigint(200)  COMMENT '事件个数',
      `exp_filter_true_ocpm_ratio` double  COMMENT '事件比例',
      `exp_filter_false_ocpm_cnt` bigint(200)  COMMENT '事件个数',
      `exp_filter_false_ocpm_ratio` double  COMMENT '事件比例',
      `win_true_cnt` bigint(200)  COMMENT '事件个数',
      `win_false_ratio` double  COMMENT '事件比例',
      `creative_total_cnt` bigint(200)  COMMENT '创意总个数',
      `order_total_cnt` bigint(200)  COMMENT '订单总数', 
      `day` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '日志时间',
      PRIMARY KEY (bucket_id,`creative_id`,creative_name,order_id,order_name,order_type,exp_ectr,creative_total_cnt,order_total_cnt,`day`)
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 
     PARTITION BY RANGE (TO_SECONDS(day))
    (
     PARTITION p20190414 VALUES LESS THAN (TO_SECONDS('20190414')) ENGINE = InnoDB,
     PARTITION p20190415 VALUES LESS THAN (TO_SECONDS('20190415')) ENGINE = InnoDB,
     PARTITION p20190416 VALUES LESS THAN (TO_SECONDS('20190416')) ENGINE = InnoDB,
     PARTITION p20190417 VALUES LESS THAN (TO_SECONDS('20190417')) ENGINE = InnoDB,
     PARTITION p20190418 VALUES LESS THAN (TO_SECONDS('20190418')) ENGINE = InnoDB,
     PARTITION p20190419 VALUES LESS THAN (TO_SECONDS('20190419')) ENGINE = InnoDB,
     PARTITION p20190420 VALUES LESS THAN (TO_SECONDS('20190420')) ENGINE = InnoDB,
     PARTITION p20190421 VALUES LESS THAN (TO_SECONDS('20190421')) ENGINE = InnoDB,
     PARTITION p20190422 VALUES LESS THAN (TO_SECONDS('20190422')) ENGINE = InnoDB,
     PARTITION p20190423 VALUES LESS THAN (TO_SECONDS('20190423')) ENGINE = InnoDB,
     PARTITION p20190424 VALUES LESS THAN (TO_SECONDS('20190424')) ENGINE = InnoDB,
     PARTITION p20190425 VALUES LESS THAN (TO_SECONDS('20190425')) ENGINE = InnoDB,
     PARTITION p20190426 VALUES LESS THAN (TO_SECONDS('20190426')) ENGINE = InnoDB,
     PARTITION p20190427 VALUES LESS THAN (TO_SECONDS('20190427')) ENGINE = InnoDB,
     PARTITION p20190428 VALUES LESS THAN (TO_SECONDS('20190428')) ENGINE = InnoDB,
     PARTITION p20190429 VALUES LESS THAN (TO_SECONDS('20190429')) ENGINE = InnoDB,
     PARTITION p20190430 VALUES LESS THAN (TO_SECONDS('20190430')) ENGINE = InnoDB,
     PARTITION p20190501 VALUES LESS THAN (TO_SECONDS('20190501')) ENGINE = InnoDB,
     PARTITION p20190502 VALUES LESS THAN (TO_SECONDS('20190502')) ENGINE = InnoDB,
     PARTITION p20190503 VALUES LESS THAN (TO_SECONDS('20190503')) ENGINE = InnoDB,
     PARTITION p20190504 VALUES LESS THAN (TO_SECONDS('20190504')) ENGINE = InnoDB,
     PARTITION p20190505 VALUES LESS THAN (TO_SECONDS('20190505')) ENGINE = InnoDB,
     PARTITION p20190506 VALUES LESS THAN (TO_SECONDS('20190506')) ENGINE = InnoDB,
     PARTITION p20190507 VALUES LESS THAN (TO_SECONDS('20190507')) ENGINE = InnoDB,
     PARTITION p20190508 VALUES LESS THAN (TO_SECONDS('20190508')) ENGINE = InnoDB,
     PARTITION p20190509 VALUES LESS THAN (TO_SECONDS('20190509')) ENGINE = InnoDB,
     PARTITION p20190510 VALUES LESS THAN (TO_SECONDS('20190510')) ENGINE = InnoDB,
     PARTITION p20190511 VALUES LESS THAN (TO_SECONDS('20190511')) ENGINE = InnoDB,
     PARTITION p20190512 VALUES LESS THAN (TO_SECONDS('20190512')) ENGINE = InnoDB,
     PARTITION p20190513 VALUES LESS THAN (TO_SECONDS('20190513')) ENGINE = InnoDB,
     PARTITION p20190514 VALUES LESS THAN (TO_SECONDS('20190514')) ENGINE = InnoDB,
     PARTITION p20190515 VALUES LESS THAN (TO_SECONDS('20190515')) ENGINE = InnoDB,
     PARTITION p20190516 VALUES LESS THAN (TO_SECONDS('20190516')) ENGINE = InnoDB,
     PARTITION p20190517 VALUES LESS THAN (TO_SECONDS('20190517')) ENGINE = InnoDB,
     PARTITION p20190518 VALUES LESS THAN (TO_SECONDS('20190518')) ENGINE = InnoDB,
     PARTITION p20190519 VALUES LESS THAN (TO_SECONDS('20190519')) ENGINE = InnoDB,
     PARTITION p20190520 VALUES LESS THAN (TO_SECONDS('20190520')) ENGINE = InnoDB);

你可能感兴趣的:(mysql)