1.key分区语句:

ALTER TABLE order_info PARTITION BY KEY(orderSn) PARTITIONS 127;

 

 

2.rang分区语句:

ALTER TABLE `table`
partition by range(to_days(entertime))
(partition P0 values less than (to_days('2018-01-01')))

这里面需要生成一套代码:

<?php

$total = 257;
$str = "ALTER TABLE `order_goods`
partition by range(to_days(addTime))
(";
$time = "2019-07-01";
for($i=0;$i<=$total;$i++){
$stringTime = date('Ym',strtotime($time));
$newTime = date('Y-m-d',strtotime("+1 month",strtotime($time)));
//$strTime = date('Ymd',strtotime("+1 month",strtotime($time)));
$time = &$newTime;


$pName = 'p'.$stringTime;

$str .=" PARTITION ".$pName." VALUES LESS THAN (to_days('".$newTime."')) ENGINE = InnoDB,<br />";
}

$str .=");";

echo $str;exit;


?>

3.删除分区表:
alter table user_collection  REMOVE PARTITIONING

相关文章:

  • 2021-12-19
  • 2021-06-08
  • 2022-03-08
  • 2022-01-02
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2021-05-29
猜你喜欢
  • 2022-01-03
  • 2021-07-09
  • 2022-01-13
  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
相关资源
相似解决方案