您好,登錄后才能下訂單哦!
本文主要給大家介紹MySQL5.5 如何分區(qū)增加刪除處理,希望可以給大家補(bǔ)充和更新些知識(shí),如有其它問題需要了解的可以持續(xù)在億速云行業(yè)資訊里面關(guān)注我的更新文章的。
一、刪除分區(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ū)
#錯(cuò)誤提示刪除存儲(chǔ)最大值分區(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
#刪除存儲(chǔ)最大值分區(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')));
看了以上關(guān)于MySQL5.5 如何分區(qū)增加刪除處理,希望能給大家在實(shí)際運(yùn)用中帶來一定的幫助。本文由于篇幅有限,難免會(huì)有不足和需要補(bǔ)充的地方,如有需要更加專業(yè)的解答,可在官網(wǎng)聯(lián)系我們的24小時(shí)售前售后,隨時(shí)幫您解答問題的。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。