MySQL中alter table range partition
最近在用MySQL開發新功能時,使用到了alter table range partition的功能,在此總結下mysql innodb支持的alter table range partition相關功能。mysql的版本是8.0.22, os: linux ubuntu
對alter range partition的操作主要由以下幾個:
analyze partition add partition drop partition truncate partition remove partitioning check partition repair partition rebuild partition reorganize partition coalesce partition每個操作對應的具體功能就不多說了,網上的說明太多了,自己找吧,主要講述SQL語句的寫法,建表語句如下:
CREATE TABLE tt ( aa int not null, bb int not null, cc int not null, primary key(aa,bb))ENGINE=innodb partition by range (aa) partitions 3 (partition p1 values less than (5) ENGINE=GreatDB,partition p2 values less than (10) ENGINE=GreatDB,partition p3 values less than (50) ENGINE=GreatDB);INSERT into tt values (1, 1, 1); INSERT into tt values (6, 1, 1); INSERT into tt values (10, 1, 1); INSERT into tt values (15, 1, 1);查詢分區name的SQL語句如下: select partition_name part, table_rows from information_schema.partitions where table_name='tt';(1)、optimize partition
innodb會提示:The storage engine for the table doesn't support optimize? 使用的mysql的版本是8.0.22. innodb也不支持這一功能
alter table tt optimize partition p1;(2)、analyze partition
alter table tt analyze partition p1; alter table tt analyze partition all;(3)、check partition
innodb會提示:The storage engine for the table doesn't support check? 使用的mysql的版本是8.0.22. innodb也不支持這一功能
alter table tt check partition p2; alter table tt check partition all;(4)、repair partition
innodb會提示:The storage engine for the table doesn't support repair? 使用的mysql的版本是8.0.22. innodb也不支持這一功能
alter table tt repair partition p3;(5)、rebuild partition
alter table tt rebuild partition all; alter table tt rebuild partition p3;(6)、reorganize partition
alter table tt reorganize partition p1, p2 into (partition p1 values less than(20));(7)、coalesce partition
alter table tt coalesce partition 1;(8)、truncate partition
alter table tt truncate partition all;(9)、add partition
ALTER TABLE tt ADD PARTITION (PARTITION p3 VALUES LESS THAN (2000));(10)、drop partition
alter table tt drop partition p3;(11)、remove partition
alter table tt remove partitioning;總之,innodb支持的alter table range partition功能就是上面的這些,代碼看mysql 8.0.22即可。
總結
以上是生活随笔為你收集整理的MySQL中alter table range partition的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tcp为什么需要3次握手和3次握手的过程
- 下一篇: 网上一些《算法(第四版)》习题答案链接