作者Wingel (百乐滑力笔)
看板Database
标题[系统] MySQL 的 Sub Partitioning
时间Thu Apr 30 22:00:06 2009
我想要建立一个以年为 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