1. 程式人生 > >Mysql 5.5+ 分割槽操作

Mysql 5.5+ 分割槽操作

查詢表分割槽資訊:

SELECT
  partition_name as part, 
  partition_expression as expr, 
  partition_description as descr, 
  table_rows 
FROM
  INFORMATION_SCHEMA.partitions 
WHERE
  TABLE_SCHEMA = schema() 
  AND TABLE_NAME='table_name'; 

分割槽:

alter table table_name partition by range(to_days(create_date))
(
partition p201906 values
less than (to_days('2019-06-31')), partition p201907 values less than (to_days('2019-07-31')) );