介紹
RANGE分區(qū)基于一個給定的連續(xù)區(qū)間范圍,早期版本RANGE主要是基于整數(shù)的分區(qū)。在5.7版本中DATE、DATETIME列也可以使用RANGE分區(qū),同時在5.5以上的版本提供了基于非整形的RANGE COLUMN分區(qū)。RANGE分區(qū)必須的連續(xù)的且不能重疊。使用
“VALUES LESS THAN ()” 來定義分區(qū)區(qū)間,非整形的范圍值需要使用單引號,并且可以使用MAXVALUE作為分區(qū)的最高值。
本文將給大家介紹MySQL 5.5 range分區(qū)增加刪除處理的相關(guān)內(nèi)容,學(xué)習(xí),下面來看看詳細(xì)的介紹:
一、刪除分區(qū)
| ##查看要處理的分區(qū)的數(shù)據(jù)量,并導(dǎo)出作為備份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)##導(dǎo)出備份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)##確認(rèn)要處理分區(qū)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 | +----+-------------+-------------------------------+------------+-------+---------------+---------+---------+------+-------+--------------------------+##刪除分區(qū)mysql> alter table baby_account_change_log drop partition p0;Query OK, 0 rows affected (0.01 sec) |
二、增加分區(qū)
| #錯誤提示刪除存儲最大值分區(qū)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#刪除存儲最大值分區(qū)mysql> alter table baby_account_change_log drop partition p12;##增加新的分區(qū)mysql> alter table baby_account_change_log add partition(PARTITION p12 VALUES LESS THAN (unix_timestamp('2017-12-31 23:59:59'))); |
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對錯新站長站的支持。
新聞熱點
疑難解答
圖片精選