Example of adding and deleting range partitions in MySQL 5.5

Example of adding and deleting range partitions in MySQL 5.5

introduce

RANGE partitioning is based on a given continuous interval range. Early versions of RANGE were mainly based on integer partitioning. In version 5.7, DATE and DATETIME columns can also use RANGE partitioning. At the same time, versions above 5.5 provide non-integer-based RANGE COLUMN partitioning. RANGE partitions must be contiguous and cannot overlap. use

"VALUES LESS THAN ()" is used to define the partition range. Non-integer range values ​​need to use single quotes, and MAXVALUE can be used as the highest value of the partition.

This article will introduce the relevant content of adding and deleting range partitions in MySQL 5.5, and share it with you for your reference and learning. Let's take a look at the detailed introduction:

1. Delete partition

##Check the amount of data in the partition to be processed and export it as a backupmysql> 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)

##Export backupmysql> 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)


##Confirm that you want to process the partitionmysql> 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 | 
+----+-------------+-------------------------------+------------+-------+---------------+---------+---------+------+------+--------------------------+

##Delete partitionmysql> alter table baby_account_change_log drop partition p0;
Query OK, 0 rows affected (0.01 sec)

2. Add partition

#Error message: delete the partition storing the maximum value 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

#Delete the partition storing the maximum valuemysql> alter table baby_account_change_log drop partition p12;

##Add a new partitionmysql> alter table baby_account_change_log add partition(PARTITION p12 VALUES LESS THAN (unix_timestamp('2017-12-31 23:59:59')));

Summarize

The above is the full content of this article. I hope that the content of this article can bring some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • How to create mysql table partitions
  • MySQL tutorial on how to use partition tables (delete partition tables)
  • Detailed explanation of MySQL table partitioning
  • Detailed introduction to MySQL partitioning technology
  • MySql data partition operation: new partition operation

<<:  Example of downloading files with vue+django

>>:  Linux kernel device driver Linux kernel module loading mechanism notes summary

Recommend

Detailed explanation of the getBoundingClientRect() method in js

1. getBoundingClientRect() Analysis The getBoundi...

How to use css variables in JS

How to use css variables in JS Use the :export ke...

Vue page monitoring user preview time function implementation code

A recent business involves such a requirement tha...

Implementation of Docker data volume operations

Getting Started with Data Volumes In the previous...

Detailed explanation of tinyMCE usage and experience

Detailed explanation of tinyMCE usage initializat...

How to install mysql on centos and set up remote access

1. Download the mysql repo source $ wget http://r...

CSS3 overflow property explained

1. Overflow Overflow is overflow (container). Whe...

Vue template configuration and webstorm code format specification settings

Table of contents 1. Compiler code format specifi...

Summary of MySQL database and table sharding

During project development, our database data is ...

mysql5.6.zip format compressed version installation graphic tutorial

Preface: MySQL is a relational database managemen...

How to use the realip module in Nginx basic learning

Preface There are two types of nginx modules, off...

Installation method of MySQL 5.7.18 decompressed version under Win7x64

Related reading: Solve the problem that the servi...

Detailed explanation of the basic usage of SSH's ssh-keygen command

SSH public key authentication is one of the SSH a...

Why Nginx is better than Apache

Nginx has taken over the majority of the Web serv...

Native JS implementation of loading progress bar

This article shares a dynamic loading progress ba...