[系統] MySQL 的 Sub Partitioning
我想要建立一個以年為 Partitioning
以月為 Sub Partitioning 的 Table
當然 Table 會設計一個日期欄位
請問有沒有人知道
MySQL 的 Sub Partitioning 能不能使用 BY RANGE 或 BY LIST 呢
下面是我目前試出能用的語法(要配合 create table 一起使用)
partition by range(year(datetime))
subpartition by hash(month(datetime))
(
partition p2008 values less than(2009)(
subpartition m200801,subpartition m200802,.......,m200812),
partition p2009 values less than(2010)(
subpartition m200901,subpartition m200902,.......,m200912),
. .
. .
. .
partition pother values less maxvalue(
subpartition mother01,subpartition mother02,.......,mother12)
);
遺憾的是,hash 無法控制各月份資料被歸入指定的月份分區
也就是希望 2008.01 月資料歸入 m200801 分區,
2008.02 月資料歸入 m200802 分區.......依此類推
原本想說那換個方法,不要使用 sub partitioning,直接
partition by range( concat( (year(datetime),'%Y') , (month(datetime),'%M') ) )
(
partition p200801 values less than (200802),
partition p200802 values less than (200803),
. .
. .
. .
partition p200812 values less than (200901),
partition p200901 values less than (200902),
. .
. .
. .
partition pother value maxvalue
);
不過行不通,好像是設定 partitioning 時不允許使用 concat() 函數
查過一些資料,應該只有 oracle 能使用 subpartition by range?
請問各路高手,MySQL 有其他方法能做到
subpartition by range 或 subpartition by list 嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.171.5.51