DROP TABLE IF EXISTS logs;
SET NAMES UTF8;
CREATE TABLE logs (
timestamp DATETIME,
message TEXT
) DEFAULT CHARSET=UTF8
PARTITION BY RANGE (TO_DAYS(timestamp)) (
PARTITION p201501 VALUES LESS THAN (TO_DAYS('2015-02-01')),
PARTITION p201502 VALUES LESS THAN (TO_DAYS('2015-03-01')),
PARTITION p201503 VALUES LESS THAN (TO_DAYS('2015-04-01')),
PARTITION pfuture VALUES LESS THAN MAXVALUE
);
SHOW CREATE TABLE logs;
Table	Create Table
logs	CREATE TABLE `logs` (
  `timestamp` datetime DEFAULT NULL,
  `message` text
) ENGINE=Mroonga DEFAULT CHARSET=utf8
 PARTITION BY RANGE (TO_DAYS(timestamp))
(PARTITION p201501 VALUES LESS THAN (735995) ENGINE = Mroonga,
 PARTITION p201502 VALUES LESS THAN (736023) ENGINE = Mroonga,
 PARTITION p201503 VALUES LESS THAN (736054) ENGINE = Mroonga,
 PARTITION pfuture VALUES LESS THAN MAXVALUE ENGINE = Mroonga)
INSERT INTO logs VALUES('2015-01-01 00:00:00', 'Start');
INSERT INTO logs VALUES('2015-01-31 23:59:59', 'Shutdown');
INSERT INTO logs VALUES('2015-02-01 00:00:00', 'Start');
INSERT INTO logs VALUES('2015-02-28 23:59:59', 'Shutdown');
INSERT INTO logs VALUES('2015-03-01 00:00:00', 'Start');
INSERT INTO logs VALUES('2015-03-31 23:59:59', 'Shutdown');
INSERT INTO logs VALUES('2015-04-01 00:00:00', 'Start');
INSERT INTO logs VALUES('2015-04-30 23:59:59', 'Shutdown');
SELECT * FROM logs ORDER BY timestamp;
timestamp	message
2015-01-01 00:00:00	Start
2015-01-31 23:59:59	Shutdown
2015-02-01 00:00:00	Start
2015-02-28 23:59:59	Shutdown
2015-03-01 00:00:00	Start
2015-03-31 23:59:59	Shutdown
2015-04-01 00:00:00	Start
2015-04-30 23:59:59	Shutdown
DROP TABLE logs;
