1、查看分区情况

SELECT PARTITION_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 'tablename';

2、分区
2-1时间戳
alter table tablename algorithm=inplace, lock=none, drop primary key, add primary key (id, time);
alter table tablename partition by range columns (time) (
    partition p1711 values less than (1512057599),
    partition p1712 values less than (1514735999),
    partition p0 values less than maxvalue
);
 
2-2字符串
alter table xw_user_applyloan_baoxian algorithm=inplace, lock=none, drop primary key, add primary key (id, time);
alter table tablename partition by range columns (UNIX_TIMESTAMP(time)) (
    partition p1711 values less than (UNIX_TIMESTAMP('2007-11-30 23:59:59')),
    partition p1712 values less than (UNIX_TIMESTAMP('2007-12-31 23:59:59')),
    partition p0 values less than maxvalue
);
 
分区说明:如果有表中有主键,分区的字段也是需要设置为主键

相关文章:

  • 2021-09-24
  • 2021-06-17
  • 2022-01-19
  • 2021-11-15
  • 2021-10-23
  • 2021-08-27
猜你喜欢
  • 2021-12-02
  • 2021-07-24
  • 2021-07-07
  • 2021-09-03
  • 2021-07-23
  • 2021-12-14
  • 2021-06-19
相关资源
相似解决方案