日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MySQL中alter table range partition

發布時間:2023/12/20 数据库 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。