存档

2010年6月 的存档

mysql之按天分区

2010年6月17日 没有评论

CREATE TABLE `newitemlog` (
`Uin` int(11) default NULL,
`ItemID` int(11) NOT NULL default ‘0’,
`ItemKey` bigint(20) NOT NULL default ‘0’,
`Operation` varchar(20) NOT NULL default ‘0’,
`time` datetime NOT NULL default ‘0000-00-00 00:00:00’,
`Count` int(11) NOT NULL default ‘0’,
`TradeID` char(32) NOT NULL default ‘0’,
`Dura` smallint(6) NOT NULL default ‘0’,
`DuraMax` smallint(6) NOT NULL default ‘0’,
`ID` int(10) unsigned NOT NULL,
KEY `IX_UIN` (`Uin`),
KEY `IX_ITEMKEY` (`ItemKey`),
PRIMARY KEY (`time`)
)
PARTITION BY RANGE (to_days(time)+8) (
    PARTITION p0 VALUES LESS THAN (20100608),
    PARTITION p1 VALUES LESS THAN (20100609),
    PARTITION p2 VALUES LESS THAN (20100610),
    PARTITION p3 VALUES LESS THAN (20100611),
    PARTITION p4 VALUES LESS THAN (20100612),
    PARTITION p5 VALUES LESS THAN (20100613),
    PARTITION p6 VALUES LESS THAN (20100614),
    PARTITION p7 VALUES LESS THAN (20100615),
    PARTITION p8 VALUES LESS THAN (20100616),
    PARTITION p9 VALUES LESS THAN (20100617),
    PARTITION p10 VALUES LESS THAN (20100618),
    PARTITION p11 VALUES LESS THAN MAXVALUE
);

to_days(time)+8 获取+8时区的日期

分类: mysql 标签: