MySQL普通表如何转换成分区表


Posted in MySQL onMay 30, 2022

版本:

MySQL-5.7.32

前言:

对于业务繁忙的数据库来说,在运行了一定时间后,往往会产生一些数据量较大的表,特别是对于每天新增数据较多的日志表或者流水表,大表对于日常的运维非常的不方便,特别是数据的清理、迁移,表的访问性能也会随着数据量的增大而受到影响,因此,对于大表我们需要进行优化拆分,通常拆分的方案有

MySQL普通表如何转换成分区表

所以,通常选择分区表改造方案的主要原因都是为了避免应用层面的改造,对应用层面透明,以及方便日常的运维,前提是表具备改造分区条件。

改造分区前期条件:

参考文档

MySQL官方文档

1 根据业务的场景以及数据的分布,确认是否有匹配的分区表类型以及分区列

  • 对于日志表,流水表这种按日期类型进行操作的,可以选择进行range分区
  • 对于按用户ID类型的进行操作的,可以选择进行hash,key分区
  • 对于按渠道,类型的进行操作的,可以选择进行list分区

2 应用涉及的sql,需要90%以上的操作都包含分区列,按分区操作,如果sql没有包含分区条件,扫描全分区,性能会出现下降。

查询表sql操作历史

select db,query,exec_count 
from sys.x$statement_analysis 
where lower(query) like '%%'order by exec_count;

3 主键必须包含分区键

4 分区键表达式只支持部分函数,存储过程,不支持二级制操作符以及/

5 分区不支持外键

查询表外键

select * 
from information_schema.KEY_COLUMN_USAGE
where constraint_schema ='' and REFERENCED_TABLE_SCHEMA is not null\G

6 不支持查询缓存

7  5.7版本单个表分区最大支持8192个,并且会话第一次访问分区表,都需要打开全部的分区表,所以避免建立过多的分区

8 数据库最大文件打开数open_files_limit要设置足够大以满足表,分区的打开数量

9 数据库大文件large_files_support设置为on

10 分区列支持null值(对于rang分区,null值总小于任何的一个非null值,即存放在最左边的分区;对于list分区需要显示指定null值条件),但从数据管理以及规范来看,不建议分区列存放null值,并且如果表有主键,则分区列不能为null值,因为分区列需要作为主键的一部分,不能为null

12 MySQL目前没有自动分区功能,所以需要监控分区的使用情况,通过job自动或者定时手动添加新分区

13 确定数据保留期限,定期归档分区数据

分区改造案例:

以下是一张数据量为766万的大表xxxx_user. xxxx_tab,计划将其改造为范围分区,按月存放。

select table_schema,table_name,table_rows,data_length/1024/1024/1024
from information_schema.tables
where table_name='xxxx_tab';

MySQL普通表如何转换成分区表

表结构

CREATE TABLE `xxxx_tab` (
  `ROLE_SEQ` bigint(20) NOT NULL ,
  `PRD_ID` varchar(64) NOT NULL ,
  `MAKE_RIGHT` varchar(1) DEFAULT '0' ,
  `CHECK_RIGHT` varchar(1) DEFAULT '0' ,
  `AUTH_RIGHT` varchar(1) DEFAULT '0' ,
  `AUTH_GROUP` varchar(4) DEFAULT NULL ,
  `RELEASE_RIGHT` varchar(1) DEFAULT '0' ,
  `CREATE_USER_SEQ` bigint(20) DEFAULT NULL ,
  `CREATE_DEPT_SEQ` bigint(20) DEFAULT NULL ,
  `CREATE_TIME` datetime DEFAULT NULL ,
  `UPDATE_USER_SEQ` bigint(20) DEFAULT NULL ,
  `UPDATE_DEPT_SEQ` bigint(20) DEFAULT NULL ,
  `UPDATE_TIME` datetime DEFAULT NULL ,
  PRIMARY KEY (`PRD_ID`,`ROLE_SEQ`),
  KEY `xxxx_tab_IDX01` (`ROLE_SEQ`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4

分区列create_time日期最大值,最小值,根据这个范围按月创建分区

select max(CREATE_TIME),min(CREATE_TIME)
from xxxx_tab;

MySQL普通表如何转换成分区表

分区列null值,对于存在的null值,需要应用对null数据进行处理,并且程序上需要确保数据写入not null

select count(*)
from xxxx_tab
where create_time is null;

MySQL普通表如何转换成分区表

主键重建添加分区列

alter table  xxxx_tab drop primary key,add primary key (`PRD_ID`,`ROLE_SEQ`,`CREATE_TIME`);

由于主键没有包含分区列,需要重建主键添加分区列,对于主键重建我采取的是官方的online ddl功能,这种ddl操作会造成主从延时,但是不会产生大量的binlog,对于主从实时性要求高的,可以采用第三方的在线工具pt-osc,gh-ost

表转化为分区表

采用pt-osc在线将表转化为分区表,对于partition by 官方是不支持online ddl的,所以需要采用第三方的在线工具

./pt-online-schema-change  --user=xxx --password=xxx --charset=utf8  D=xxxx_user,t=xxxx_tab  --alter "PARTITION BY RANGE  COLUMNS(CREATE_TIME)
(PARTITION p200001 VALUES LESS THAN ('2000-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p200101 VALUES LESS THAN ('2001-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201707 VALUES LESS THAN ('2017-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201708 VALUES LESS THAN ('2017-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201709 VALUES LESS THAN ('2017-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201710 VALUES LESS THAN ('2017-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201711 VALUES LESS THAN ('2017-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201712 VALUES LESS THAN ('2018-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201801 VALUES LESS THAN ('2018-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201802 VALUES LESS THAN ('2018-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201803 VALUES LESS THAN ('2018-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201804 VALUES LESS THAN ('2018-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201805 VALUES LESS THAN ('2018-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201806 VALUES LESS THAN ('2018-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201807 VALUES LESS THAN ('2018-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201808 VALUES LESS THAN ('2018-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201809 VALUES LESS THAN ('2018-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201810 VALUES LESS THAN ('2018-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201811 VALUES LESS THAN ('2018-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201812 VALUES LESS THAN ('2019-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201901 VALUES LESS THAN ('2019-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201902 VALUES LESS THAN ('2019-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201903 VALUES LESS THAN ('2019-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201904 VALUES LESS THAN ('2019-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201905 VALUES LESS THAN ('2019-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201906 VALUES LESS THAN ('2019-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201907 VALUES LESS THAN ('2019-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201908 VALUES LESS THAN ('2019-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201909 VALUES LESS THAN ('2019-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201910 VALUES LESS THAN ('2019-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201911 VALUES LESS THAN ('2019-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201912 VALUES LESS THAN ('2020-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202001 VALUES LESS THAN ('2020-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202002 VALUES LESS THAN ('2020-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202003 VALUES LESS THAN ('2020-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202004 VALUES LESS THAN ('2020-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202005 VALUES LESS THAN ('2020-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202006 VALUES LESS THAN ('2020-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202007 VALUES LESS THAN ('2020-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202008 VALUES LESS THAN ('2020-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202009 VALUES LESS THAN ('2020-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202010 VALUES LESS THAN ('2020-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202011 VALUES LESS THAN ('2020-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202012 VALUES LESS THAN ('2021-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202101 VALUES LESS THAN ('2021-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202102 VALUES LESS THAN ('2021-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202103 VALUES LESS THAN ('2021-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202104 VALUES LESS THAN ('2021-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202105 VALUES LESS THAN ('2021-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202106 VALUES LESS THAN ('2021-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202107 VALUES LESS THAN ('2021-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202108 VALUES LESS THAN ('2021-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202109 VALUES LESS THAN ('2021-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202110 VALUES LESS THAN ('2021-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202111 VALUES LESS THAN ('2021-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202112 VALUES LESS THAN ('2022-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202201 VALUES LESS THAN ('2022-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202202 VALUES LESS THAN ('2022-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202203 VALUES LESS THAN ('2022-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202204 VALUES LESS THAN ('2022-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202205 VALUES LESS THAN ('2022-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202206 VALUES LESS THAN ('2022-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202207 VALUES LESS THAN ('2022-08-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202208 VALUES LESS THAN ('2022-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202209 VALUES LESS THAN ('2022-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202210 VALUES LESS THAN ('2022-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202211 VALUES LESS THAN ('2022-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202212 VALUES LESS THAN ('2023-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202301 VALUES LESS THAN ('2023-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202302 VALUES LESS THAN ('2023-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202303 VALUES LESS THAN ('2023-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202304 VALUES LESS THAN ('2023-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202305 VALUES LESS THAN ('2023-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202306 VALUES LESS THAN ('2023-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202307 VALUES LESS THAN ('2023-08-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202308 VALUES LESS THAN ('2023-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202309 VALUES LESS THAN ('2023-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202310 VALUES LESS THAN ('2023-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202311 VALUES LESS THAN ('2023-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202312 VALUES LESS THAN ('2024-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION pmax VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB)"  --recursion-method hosts --max-lag 600  --nodrop-old-table --print --statistics --execute

分区后表模型

CREATE TABLE `xxxx_tab` (
  `ROLE_SEQ` bigint(20) NOT NULL ,
  `PRD_ID` varchar(64) NOT NULL ,
  `MAKE_RIGHT` varchar(1) DEFAULT '0' ,
  `CHECK_RIGHT` varchar(1) DEFAULT '0' ,
  `AUTH_RIGHT` varchar(1) DEFAULT '0' ,
  `AUTH_GROUP` varchar(4) DEFAULT NULL ,
  `RELEASE_RIGHT` varchar(1) DEFAULT '0' ,
  `CREATE_USER_SEQ` bigint(20) DEFAULT NULL ,
  `CREATE_DEPT_SEQ` bigint(20) DEFAULT NULL ,
  `CREATE_TIME` datetime NOT NULL ,
  `UPDATE_USER_SEQ` bigint(20) DEFAULT NULL ,
  `UPDATE_DEPT_SEQ` bigint(20) DEFAULT NULL ,
  `UPDATE_TIME` datetime DEFAULT NULL ,
  PRIMARY KEY (`PRD_ID`,`ROLE_SEQ`,`CREATE_TIME`),
  KEY `xxxx_tab_IDX01` (`ROLE_SEQ`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 
PARTITION BY RANGE  COLUMNS(CREATE_TIME)
(PARTITION p200001 VALUES LESS THAN ('2000-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p200101 VALUES LESS THAN ('2001-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201707 VALUES LESS THAN ('2017-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201708 VALUES LESS THAN ('2017-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201709 VALUES LESS THAN ('2017-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201710 VALUES LESS THAN ('2017-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201711 VALUES LESS THAN ('2017-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201712 VALUES LESS THAN ('2018-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201801 VALUES LESS THAN ('2018-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201802 VALUES LESS THAN ('2018-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201803 VALUES LESS THAN ('2018-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201804 VALUES LESS THAN ('2018-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201805 VALUES LESS THAN ('2018-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201806 VALUES LESS THAN ('2018-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201807 VALUES LESS THAN ('2018-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201808 VALUES LESS THAN ('2018-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201809 VALUES LESS THAN ('2018-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201810 VALUES LESS THAN ('2018-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201811 VALUES LESS THAN ('2018-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201812 VALUES LESS THAN ('2019-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201901 VALUES LESS THAN ('2019-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201902 VALUES LESS THAN ('2019-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201903 VALUES LESS THAN ('2019-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201904 VALUES LESS THAN ('2019-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201905 VALUES LESS THAN ('2019-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201906 VALUES LESS THAN ('2019-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201907 VALUES LESS THAN ('2019-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p201908 VALUES LESS THAN ('2019-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201909 VALUES LESS THAN ('2019-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201910 VALUES LESS THAN ('2019-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201911 VALUES LESS THAN ('2019-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p201912 VALUES LESS THAN ('2020-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202001 VALUES LESS THAN ('2020-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202002 VALUES LESS THAN ('2020-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202003 VALUES LESS THAN ('2020-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202004 VALUES LESS THAN ('2020-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202005 VALUES LESS THAN ('2020-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202006 VALUES LESS THAN ('2020-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202007 VALUES LESS THAN ('2020-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202008 VALUES LESS THAN ('2020-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202009 VALUES LESS THAN ('2020-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202010 VALUES LESS THAN ('2020-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202011 VALUES LESS THAN ('2020-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202012 VALUES LESS THAN ('2021-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202101 VALUES LESS THAN ('2021-02-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202102 VALUES LESS THAN ('2021-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202103 VALUES LESS THAN ('2021-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202104 VALUES LESS THAN ('2021-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202105 VALUES LESS THAN ('2021-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202106 VALUES LESS THAN ('2021-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202107 VALUES LESS THAN ('2021-08-01 00:00:00') ENGINE = InnoDB, 
 PARTITION p202108 VALUES LESS THAN ('2021-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202109 VALUES LESS THAN ('2021-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202110 VALUES LESS THAN ('2021-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202111 VALUES LESS THAN ('2021-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202112 VALUES LESS THAN ('2022-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202201 VALUES LESS THAN ('2022-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202202 VALUES LESS THAN ('2022-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202203 VALUES LESS THAN ('2022-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202204 VALUES LESS THAN ('2022-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202205 VALUES LESS THAN ('2022-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202206 VALUES LESS THAN ('2022-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202207 VALUES LESS THAN ('2022-08-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202208 VALUES LESS THAN ('2022-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202209 VALUES LESS THAN ('2022-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202210 VALUES LESS THAN ('2022-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202211 VALUES LESS THAN ('2022-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202212 VALUES LESS THAN ('2023-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202301 VALUES LESS THAN ('2023-02-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202302 VALUES LESS THAN ('2023-03-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202303 VALUES LESS THAN ('2023-04-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202304 VALUES LESS THAN ('2023-05-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202305 VALUES LESS THAN ('2023-06-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202306 VALUES LESS THAN ('2023-07-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202307 VALUES LESS THAN ('2023-08-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202308 VALUES LESS THAN ('2023-09-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202309 VALUES LESS THAN ('2023-10-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202310 VALUES LESS THAN ('2023-11-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202311 VALUES LESS THAN ('2023-12-01 00:00:00') ENGINE = InnoDB,
 PARTITION p202312 VALUES LESS THAN ('2024-01-01 00:00:00') ENGINE = InnoDB,
 PARTITION pmax VALUES LESS THAN (MAXVALUE) ENGINE = InnoDB)

总结

到此这篇关于MySQL普通表如何转换成分区表的文章就介绍到这了!


Tags in this post...

MySQL 相关文章推荐
mysql多表查询-笔记七
Apr 05 MySQL
IDEA 链接Mysql数据库并执行查询操作的完整代码
May 20 MySQL
.Net Core导入千万级数据至Mysql的步骤
May 24 MySQL
MySQL下使用Inplace和Online方式创建索引的教程
May 26 MySQL
MySQL 常见的数据表设计误区汇总
Jun 07 MySQL
MySQL 数据恢复的多种方法汇总
Jun 21 MySQL
解决mysql问题:由于找不到MSVCR120.dll,无法继续执行代码
Jun 26 MySQL
解决mysql的int型主键自增问题
Jul 15 MySQL
mysql的数据压缩性能对比详情
Nov 07 MySQL
如何创建一个创建MySQL数据库中的datetime类型
Mar 21 MySQL
mysql的单列多值存储实例详解
Apr 05 MySQL
Mysql将字符串按照指定字符分割的正确方法
May 30 #MySQL
MySQL数据库安装方法与图形化管理工具介绍
MySQL数据库简介与基本操作
May 30 #MySQL
Mysql数据库事务的脏读幻读及不可重复读详解
May 30 #MySQL
mysql字段为NULL索引是否会失效实例详解
May 30 #MySQL
MYSQL如何查看操作日志详解
sql查询语句之平均分、最高最低分及排序语句
May 30 #MySQL
You might like
php+AJAX传送中文会导致乱码的问题的解决方法
2008/09/08 PHP
Smarty高级应用之缓存操作技巧分析
2016/05/14 PHP
php Session无效分析资料整理
2016/11/29 PHP
PHP使用星号替代用户名手机和邮箱的实现代码
2018/02/07 PHP
使用js获取QueryString的方法小结
2010/02/28 Javascript
JQuery EasyUI 对话框的使用方法
2010/10/24 Javascript
jQuery Animation实现CSS3动画示例介绍
2013/08/14 Javascript
javascript闭包传参和事件的循环绑定示例探讨
2014/04/17 Javascript
jquery操作HTML5 的data-*的用法实例分享
2014/08/17 Javascript
jquery实现浮动的侧栏实例
2015/06/25 Javascript
深入浅析JavaScript字符串操作方法 slice、substr、substring及其IE兼容性
2015/12/16 Javascript
js操作数据库实现注册和登陆的简单实例
2016/05/26 Javascript
jQuery增加、删除及修改select option的方法
2016/08/19 Javascript
利用Angular.js限制textarea输入的字数
2016/10/20 Javascript
webpack配置文件和常用配置项介绍
2017/04/28 Javascript
Bootstrap组件之下拉菜单,多级菜单及按钮布局方法实例
2017/05/25 Javascript
js实现从左向右滑动式轮播图效果
2017/07/07 Javascript
浅谈vue,angular,react数据双向绑定原理分析
2017/11/28 Javascript
laravel实现中文和英语互相切换的例子
2019/09/30 Javascript
[17:36]VG战队纪录片
2014/08/21 DOTA
[32:07]完美世界DOTA2联赛PWL S3 LBZS vs Rebirth 第一场 12.16
2020/12/17 DOTA
浅谈python中的正则表达式(re模块)
2017/10/17 Python
PyTorch基本数据类型(一)
2019/05/22 Python
在python下使用tensorflow判断是否存在文件夹的实例
2019/06/10 Python
基于python cut和qcut的用法及区别详解
2019/11/22 Python
使用CSS3来实现滚动视差效果的教程
2015/08/24 HTML / CSS
美国韩国化妆品和护肤品购物网站:Beautytap
2018/07/29 全球购物
大学生毕业求职简历的自我评价
2013/10/24 职场文书
经典广告词大全
2014/03/14 职场文书
委托书范文
2014/04/02 职场文书
教师求职信
2014/06/17 职场文书
幼儿园百日安全活动总结
2015/05/07 职场文书
被告答辩状范文
2015/05/22 职场文书
Python读取文件夹下的所有文件实例代码
2021/04/02 Python
golang判断key是否在map中的代码
2021/04/24 Golang
Python中的嵌套循环详情
2022/03/23 Python