• mysql range 分区


    mysql> show create table historyG;
    *************************** 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

  • 相关阅读:
    如何实现文字两端对齐?
    三目运算符的复杂运算(条件嵌套判断)
    微信小程序实现图片上传,预览,删除
    微信小程序滚动条返回顶部
    vue+axios下载文件的实现
    java script 运算符
    关于placeholder提示内容出现在textarea底部问题
    js基础知识
    java script 字符串
    java script 函数
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351474.html
Copyright © 2020-2023  润新知