MySQL5.5 RANGE分区增加删除处理

栏目: 数据库 · 发布时间: 7年前

内容简介:MySQL5.5 RANGE分区增加删除处理

一、删除分区

##查看要处理的分区的数据量,并导出作为备份

mysql> select count(*)  from baby_account_change_log where updated_time >'2016-12-01 00:00:00' and updated_time <'2017-01-01 00:00:00';

+----------+

| count(*) |

+----------+

|    66252 |

+----------+

1 row in set (0.23 sec)

##导出备份

mysql> select *  into outfile '/tmp/baby_account_change_log_p1.sql' from baby_account_change_log where updated_time >'2016-12-01 00:00:00' and updated_time <'2017-01-01 00:00:00' limit 100000000000;

Query OK, 66252 rows affected (2.71 sec)

##确认要处理分区

mysql> explain partitions select count(*)  from baby_account_change_log where updated_time >'2016-12-01 00:00:00' and updated_time <'2017-01-01 00:00:00';

+----+-------------+-------------------------------+------------+-------+---------------+---------+---------+------+-------+--------------------------+

| id | select_type | table                         | partitions | type  | possible_keys | key     | key_len | ref  | rows  | Extra                    |

+----+-------------+-------------------------------+------------+-------+---------------+---------+---------+------+-------+--------------------------+

|  1 | SIMPLE      | baby_account_change_log | p1 | index | NULL          | PRIMARY | 8       | NULL | 66252 | Using where; Using index | 

+----+-------------+-------------------------------+------------+-------+---------------+---------+---------+------+-------+--------------------------+

##删除分区

mysql> alter table baby_account_change_log drop partition p0;

Query OK, 0 rows affected (0.01 sec)

二、增加分区

#错误提示删除存储最大值分区

mysql> alter table baby_account_change_log add partition(PARTITION p13 VALUES LESS THAN (unix_timestamp('2017-12-31 23:59:59')));

ERROR 1481 (HY000): MAXVALUE can only be used in last partition definition

#删除存储最大值分区

mysql> alter table baby_account_change_log drop partition p12;

##增加新的分区

mysql> alter table baby_account_change_log add partition(PARTITION p12 VALUES LESS THAN (unix_timestamp('2017-12-31 23:59:59')));


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

B端产品经理必修课

B端产品经理必修课

李宽 / 电子工业出版社 / 2018-9 / 59

《B端产品经理必修课:从业务逻辑到产品构建全攻略》主要讲述了“单个产品管理流程”,以展示B 端产品经理的工作方法及B 端产品的设计方法。《B端产品经理必修课:从业务逻辑到产品构建全攻略》分为三个部分。第一部分主要讲述的是B 端产品经理的工作流程和定义(即单个产品管理流程),以及从事B 端产品经理的职业现状和规划,还包括设计B 端产品时需要了解的指导思想。第二部分是通过各个章节来讲述单个产品管理流程......一起来看看 《B端产品经理必修课》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换