to_days()

Given a date date, returns a day number (the number of days since year 0).

给定一个date 日期,返回天数

Create Table: CREATE TABLE `ClientActionTrack` (
`sn` bigint(20) NOT NULL AUTO_INCREMENT,
`clientSn` int(11) DEFAULT NULL,
`ip` varchar(32) DEFAULT NULL,
`url` varchar(1000) DEFAULT NULL COMMENT 'request url',
`httpMethod` varchar(100) DEFAULT NULL COMMENT 'http method',
`requestParams` text COMMENT '请求参数',
`requestHeader` varchar(2000) DEFAULT NULL COMMENT '请求头信息',
`pageUrl` varchar(500) DEFAULT NULL COMMENT '页面Url',
`sessionId` varchar(100) DEFAULT NULL COMMENT 'session的Id',
`startTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '访问开始时间',
`completeTime` datetime DEFAULT NULL COMMENT '访问完成时间',
PRIMARY KEY (`sn`,`startTime`)
) ENGINE=InnoDB AUTO_INCREMENT=4424745 DEFAULT CHARSET=utf8 COMMENT='用户访问记录表'
/*!50100 PARTITION BY RANGE (TO_DAYS(startTime))
(PARTITION p20151204 VALUES LESS THAN (736302) ENGINE = InnoDB,
PARTITION p20151205 VALUES LESS THAN (736303) ENGINE = InnoDB,
PARTITION p20151206 VALUES LESS THAN (736304) ENGINE = InnoDB,
PARTITION p20151207 VALUES LESS THAN (736305) ENGINE = InnoDB,
PARTITION p20151208 VALUES LESS THAN (736306) ENGINE = InnoDB,
PARTITION p20151209 VALUES LESS THAN (736307) ENGINE = InnoDB, PARTITION p20160824 VALUES LESS THAN (736566) ENGINE = InnoDB, ##小于'2016-08-25 23:59:47'
PARTITION p20160825 VALUES LESS THAN (736567) ENGINE = InnoDB,
PARTITION p20160826 VALUES LESS THAN (736568) ENGINE = InnoDB,
PARTITION p20160827 VALUES LESS THAN (736569) ENGINE = InnoDB, mysql> select TO_DAYS('2016-08-25 23:59:47') from Client limit 1;
+--------------------------------+
| TO_DAYS('2016-08-25 23:59:47') |
+--------------------------------+
| 736566 |
+--------------------------------+
1 row in set (0.00 sec) mysql> select TO_DAYS('2016-08-26 23:59:47') from Client limit 1;
+--------------------------------+
| TO_DAYS('2016-08-26 23:59:47') |
+--------------------------------+
| 736567 |
+--------------------------------+
1 row in set (0.00 sec) mysql> SELECT min(startTime),max(startTime) from ClientActionTrack PARTITION (p20160825);
+---------------------+---------------------+
| min(startTime) | max(startTime) |
+---------------------+---------------------+
| 2016-08-25 00:04:57 | 2016-08-25 23:59:47 |
+---------------------+---------------------+
1 row in set (0.03 sec) mysql> select min(startTime),max(startTime) from ClientActionTrack where startTime>'2016-08-25 00:00:00' and startTime<'2016-08-25 23:59:00';
+---------------------+---------------------+
| min(startTime) | max(startTime) |
+---------------------+---------------------+
| 2016-08-25 00:04:57 | 2016-08-25 23:57:57 |
+---------------------+---------------------+
1 row in set (0.03 sec)

mysql 分区 按 PARTITION BY RANGE (TO_DAYS(startTime))的更多相关文章

  1. 深入解析MySQL分区(Partition)功能

    自5.1开始对分区(Partition)有支持 = 水平分区(根据列属性按行分)= 举个简单例子:一个包含十年发票记录的表可以被分区为十个不同的分区,每个分区包含的是其中一年的记录. === 水平分区 ...

  2. MySQL分区(Partition)功能

    引用地址:http://blog.csdn.net/tjcyjd/article/details/11194489 自5.1开始对分区(Partition)有支持 = 水平分区(根据列属性按行分)=举 ...

  3. mysql分区(partition)

    1)按范分区(range) partition by range(Year(birthday))( partition p0 values less than 1960, partition p1 v ...

  4. mysql分区表之三:MySQL分区建索引[转]

    介绍 mysql分区后每个分区成了独立的文件,虽然从逻辑上还是一张表其实已经分成了多张独立的表,从“information_schema.INNODB_SYS_TABLES”系统表可以看到每个分区都存 ...

  5. [转] mysql分区性能初探

    本文转自:http://www.cnblogs.com/acpp/archive/2010/08/09/1795464.html 一,      分区概念  分区允许根据指定的规则,跨文件系统分配单个 ...

  6. (转)mysql分区技术2

    转:http://database.51cto.com/art/201002/184392.htm 非整数列分区 任何使用过分区的人应该都遇到过不少问题,特别是面对非整数列分区时,MySQL 5.1只 ...

  7. mysql分区与分表的区别

    分区 分区就是把一个数据表的文件和索引分散存储在不同的物理文件中. mysql支持的分区类型包括Range.List.Hash.Key,其中Range比较常用: RANGE分区:基于属于一个给定连续区 ...

  8. mysql 分区处理数据

    记录一下分区代码: 1.建立存储过程,将原表按照时间转化为分区表,并建立当天分区 #alter table to partition table DELIMITER $$ USE `dc_log`$$ ...

  9. Mysql分区的技能

    1. 查看分区信息 (1)explain partitions select * from TDM_YTMF_BRAND_CATE_GDS_STC_D 语法:explain partitions se ...

随机推荐

  1. [转]让Sublime Text2支持浏览器中预览

    转自http://www.imququ.com/post/view-sublime-text-2-file-in-browser.html 1.点击菜单Tools -> New Plugin.. ...

  2. cxf2.7.10与Spring3.0.5集成时报错如下

    严重: Error listenerStart 2014-3-29 22:25:20 org.apache.catalina.core.StandardContext start 严重: Contex ...

  3. SPOJDIVCNT2: Counting Divisors(莫比乌斯反演)

    http://acm.tzc.edu.cn/acmhome/vProblemList.do?method=problemdetail&oj=SPOJ&pid=DIVCNT2 给出n求 ...

  4. javascript之Boolean

    一.new Boolean(value); //构造函数 Boolean(value); //转换函数 0,NaN,null,"",undefined都会转成false,其他都会返 ...

  5. JavaScript prototype.js提升JavaScript开发效率

    参考链接:http://www.yiibai.com/prototype/ Prototype提供主要方法类别: Prototype概述 Prototype实用功能 Prototype实用方法 Pro ...

  6. BFS visit tree

    There are two ways to conduct BFS on tree. Solution 1 -- Given level Use recursion to find given lev ...

  7. Windows Azure功能更新:Oracle软件正式登陆Azure了

    今天,Windows Azure国际版发布了新的功能:全面支持Oracle软件,包括Oracle Linux, Oracle 12c数据库,Weblogic 11g和12c,Oracle JDK 6和 ...

  8. Ffmpeg和SDL创建线程(转)

    Spawning Threads Overview Last time we added audio support by taking advantage of SDL's audio functi ...

  9. 多媒体封装格式----mkv

    Matroska 开源多媒体容器标准.MKV属于其中的一部分.Matroska常见的有.MKV视频格式.MKA音频格式..MKS字幕格式..MK3D files (stereoscopic/3D vi ...

  10. 【Java基础】构造方法调用构造方法

    从一个程序开始: class dog { private String name; private String color; private int age; dog(String name) // ...