mysql 按照日期分区

 

1.分区的字段必须主键其中之一;

 

ALTER TABLE zj_node_price ADD PRIMARY KEY (id,data_date);

ALTER TABLE zj_node_price ADD INDEX u_data_date (data_date)

 

alter table zj_node_price partition by range COLUMNS(data_date) (

partition p20241101 values less than ('2024-11-01'),

partition p20241102 values less than ('2024-11-02'),

partition p20241103 values less than ('2024-11-03'),

partition px values less than maxvalue

);

 

 

posted @ 2024-11-19 16:37  黑狗已醒  阅读(15)  评论(0编辑  收藏  举报