mysql range分区 type_mysql range 分区

mysql> show create table history\G;

*************************** 1. row ***************************

Table: history

Create Table: CREATE TABLE `history` (

`itemid` bigint(20) unsigned NOT NULL,

`clock` int(11) NOT NULL DEFAULT '0',

`value` double(16,4) NOT NULL DEFAULT '0.0000',

`ns` int(11) NOT NULL DEFAULT '0',

KEY `history_1` (`itemid`,`clock`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8

/*!50100 PARTITION BY RANGE (clock)

(PARTITION p20150806 VALUES LESS THAN (1438876800) ENGINE = InnoDB,

PARTITION p20150807 VALUES LESS THAN (1438963200) ENGINE = InnoDB,

PARTITION p20150808 VALUES LESS THAN (1439049600) ENGINE = InnoDB,

PARTITION p20150809 VALUES LESS THAN (1439136000) ENGINE = InnoDB,

PARTITION p20150810 VALUES LESS THAN (1439222400) ENGINE = InnoDB,

PARTITION p20150811 VALUES LESS THAN (1439308800) ENGINE = InnoDB,

PARTITION p20150812 VALUES LESS THAN (1439395200) ENGINE = InnoDB,

PARTITION p20150813 VALUES LESS THAN (1439481600) ENGINE = InnoDB,

[root@master ~]# date -d@1438857116 "+%Y-%m-%d"

2015-08-06

[root@master ~]# date -d@1438909741 "+%Y-%m-%d"

2015-08-07

mysql> select min(clock),max(clock) from history;

+------------+------------+

| min(clock) | max(clock) |

+------------+------------+

| 1438857116 | 1438909857 |

+------------+------------+

1 row in set (0.01 sec)

mysql> select min(clock),max(clock) from history partition(p20150806);

+------------+------------+

| min(clock) | max(clock) |

+------------+------------+

| 1438857116 | 1438876797 |

+------------+------------+

1 row in set (0.00 sec)

[root@master ~]# date -d@1438857116 "+%Y-%m-%d"

2015-08-06

[root@master ~]# date -d@1438876797 "+%Y-%m-%d"

2015-08-06

mysql> select min(clock),max(clock) from history partition(p20150807);

+------------+------------+

| min(clock) | max(clock) |

+------------+------------+

| 1438876800 | 1438909861 |

+------------+------------+

1 row in set (0.00 sec)

[root@master ~]# date -d@1438876799 "+%Y-%m-%d"

2015-08-06

[root@master ~]# date -d@1438876800 "+%Y-%m-%d"

2015-08-07

[root@master ~]# date -d@1438909861 "+%Y-%m-%d"

2015-08-07

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值