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 root密码的重置方法
Apr 21 MySQL
MySQL 重写查询语句的三种策略
May 10 MySQL
MySQL 分页查询的优化技巧
May 12 MySQL
MySQL 数据类型选择原则
May 27 MySQL
MySQL注入基础练习
May 30 MySQL
python中的mysql数据库LIKE操作符详解
Jul 01 MySQL
MySQL 8.0 驱动与阿里druid版本兼容问题解决
Jul 01 MySQL
MySql 缓存查询原理与缓存监控和索引监控介绍
Jul 02 MySQL
MySQL系列之五 视图、存储函数、存储过程、触发器
Jul 02 MySQL
MySQL系列之十 MySQL事务隔离实现并发控制
Jul 02 MySQL
SQL实现LeetCode(177.第N高薪水)
Aug 04 MySQL
MySQL如何修改字段类型和字段长度
Jun 10 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)
2010/09/04 PHP
php原生导出excel文件的两种方法(推荐)
2016/11/19 PHP
PHP设计模式之状态模式定义与用法详解
2018/04/02 PHP
Yii2框架操作数据库的方法分析【以mysql为例】
2019/05/27 PHP
从javascript语言本身谈项目实战
2006/12/27 Javascript
Ext JS Grid在IE6 下宽度的问题解决方法
2009/02/15 Javascript
P3P Header解决Cookie跨域的问题
2013/03/12 Javascript
JQuery 使用attr方法实现下拉列表选中
2014/10/13 Javascript
使用jspdf生成pdf报表
2015/07/03 Javascript
C++中的string类的用法小结
2015/08/07 Javascript
JavaScript简单实现弹出拖拽窗口(二)
2016/06/17 Javascript
深入理解jQuery layui分页控件的使用
2016/08/17 Javascript
Javascript生成带参数的二维码示例
2016/10/10 Javascript
简单实现IONIC购物车功能
2017/01/10 Javascript
JQuery查找子元素find()和遍历集合each的方法总结
2017/03/07 Javascript
Node调用Java的示例代码
2017/09/20 Javascript
vue安装遇到的5个报错及解决方法
2019/06/12 Javascript
jquery更改元素属性attr()方法操作示例
2020/05/22 jQuery
[06:16]《DAC最前线》之地区预选赛全面回顾
2015/01/19 DOTA
python连接mysql调用存储过程示例
2014/03/05 Python
Python写的PHPMyAdmin暴力破解工具代码
2014/08/06 Python
python自动格式化json文件的方法
2015/03/11 Python
Python使用metaclass实现Singleton模式的方法
2015/05/05 Python
python机器学习实战之最近邻kNN分类器
2017/12/20 Python
使用python爬虫实现网络股票信息爬取的demo
2018/01/05 Python
Python中循环引用(import)失败的解决方法
2018/04/22 Python
英国虚拟主机服务商:eUKhost
2016/08/16 全球购物
Schecker荷兰:狗狗用品和配件
2019/06/06 全球购物
美国在线肉类和海鲜配送:Crowd Cow
2020/10/02 全球购物
PHP如何防止SQL注入
2014/05/03 面试题
力学专业毕业生自荐信
2013/11/17 职场文书
金融专业毕业生推荐信
2013/11/26 职场文书
一份没有按时交货失信于客户的检讨书
2014/09/19 职场文书
婚庆主持词大全
2015/06/30 职场文书
Go语言实现Base64、Base58编码与解码
2021/07/26 Golang
《堡垒之夜》联动《刺客信条》 4月7日正式上线
2022/04/06 其他游戏