实验环境:3节点,RHEL6.4 + Vertica 7.0.1
实验目的:了解Vertica数据库的date与timestamp数据类型,to_date()与to_timestamp()函数区别
 
构造的实验表中只有10条记录。
1.查询表记录数据如下:
irnop=> select start_time from perf_rnc_w_3;
start_time
---------------------
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
2014-05-26 01:00:00
(10 rows)
2.实验过程:
2.1用to_date()查询5.26号0点~23点间的记录数,结果不是预期的结果,是0条:
irnop=> select count(*) from perf_rnc_w_3 where start_time >= to_date('2014-05-26 00:00:00','yyyy-MM-dd hh24:mi:ss')
irnop-> and start_time <to_date('2014-05-26 23:00:00','yyyy-MM-dd hh24:mi:ss');
count
-------
0
(1 row)
irnop=>
2.2用to_timestamp()查询5.26号0点~23点间的记录数,结果正确显示为10条:
irnop=> select count(*) from perf_rnc_w_3 where start_time >= to_timestamp('2014-05-26 00:00:00','yyyy-MM-dd hh24:mi:ss')
irnop-> and start_time <to_timestamp('2014-05-26 23:00:00','yyyy-MM-dd hh24:mi:ss');
count
-------
10
(1 row)
2.3用to_timestamp()查询5.26号2点及以后的记录数,实际是没有符合条件数据的,结果正确显示为0条:
irnop=> select count(*) from perf_rnc_w_3 where start_time >= to_timestamp('2014-05-26 02:00:00','yyyy-MM-dd hh24:mi:ss');
count
-------
0
(1 row)
2.4用to_date()查询5.26号2点及以后的记录数,实际是没有符合条件数据的,但结果此时却是10条:
irnop=> select count(*) from perf_rnc_w_3 where start_time >= to_date('2014-05-26 02:00:00','yyyy-MM-dd hh24:mi:ss');
count
-------
10
(1 row)
 
3.总结:
vertica时间类型为date的不精确到小时\分\秒, 

如果需要,定义的时间数据类型必须为timestamp。
同样,查询,vertica的to_date()函数不精确到小时\分\秒,
如果需要,需要用to_timestamp()函数。

 
4.延伸:

oracle数据库的date包括精确到时分秒,所以在oracle—>vertica迁移场景中,建议将oracle的date数据类型修改为vertica的timestamp。
网络搜索到vertica date和timestamp的数据类型介绍:
DATE 8 Represents a month, day, and year
TIMESTAMP 8 Represents a date and time without timezone
更多vertica数据类型介绍参见:http://www.cnblogs.com/jyzhao/articles/3778948.html

最新文章

  1. Hibernate(1)——数据访问层的架构模式
  2. 事件流之事件冒泡与事件捕获&lt;JavaScript高级程序设计&gt;学习笔记
  3. 聊聊 Web 项目二维码生成的最佳姿势
  4. strtok&amp;strsep
  5. Spring的DI(Ioc) - 注入bean 和 基本数据类型
  6. 不包含适合于入口点的静态&quot;Main&quot;方法
  7. rsync 无密码 传输
  8. java集合类之------Properties
  9. 解密电子书之三:MCU(君正)
  10. AnsiString 在 Delphi 中虽然不可用,但是,在 C++ 中可以用
  11. windows下建立文件的换行符^M导致linux下的shell脚本执行错误的解决方式
  12. C#枚举数和迭代器
  13. listbox控件使用
  14. Linux-Nginx+rtmp+ffmpeg搭建流媒体服务器
  15. C# 如何在PDF中绘制不同风格类型的文本
  16. 【HNOI 2017】大佬
  17. 2955 ACM 杭电 抢银行 01背包 乘法
  18. 3.1Python数据处理篇之Numpy系列(一)---ndarray对象的属性与numpy的数据类型
  19. Transfrom笔记
  20. 论 数据库 B Tree 索引 在 固态硬盘 上 的 离散存储

热门文章

  1. #iOS问题记录# 关于UITableViewcel的分割线去掉问题
  2. 纯css3 Star
  3. eclipse创建Maven-web项目(-)
  4. CSS的定位
  5. canvas初探1
  6. 协议分析 - DHCP协议解码详解
  7. 浅谈Android应用保护(零):出发点和背景
  8. Linux环境下部署完JDK后运行一个简单的Java程序
  9. java中文乱码解决之道(五)-----java是如何编码解码的
  10. logistic回归