mysql分區那些事

來源:互聯網
上載者:User

標籤:操作   list   remove   exp   介紹   drop   table   lte   val   

 mysql中的分區有range、list、hash、key四種分區方法
 我們這裡介紹range方法,其他的可以融會貫通

 

對已有表進行分區(range模式)

 ALTER TABLE 表名 PARTITION by range(欄位名) (PARTITION 分區名  VALUES LESS THAN (欄位值) );
alter TABLE user_log PARTITION by range(id)(        PARTITION user_log_a VALUES less than (17),        PARTITION user_log_b VALUES less than (20),        PARTITION user_log_c VALUES less than (MAXVALUE));

查看分區情況

EXPLAIN PARTITIONS SELECT * from user_log

 

查詢制定分區

SELECT * from user_log PARTITION(user_log_a);SELECT * from user_log PARTITION(user_log_b);select * from user_log PARTITION(user_log_c);

其他動作命令

合并alter table 表名reorganize partition 分區名1,分區名2 into(partition 分區名 values less than (xx));刪除分區alter table 表名drop partition 分區名;(丟資料)刪除分區 (不丟資料)Alter table news_main remove partitioning;

 

mysql分區那些事

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.