https://img2020.cnblogs.com/blog/1101843/202010/1101843-20201029092119794-1182278230.jpg

支付宝

https://img2020.cnblogs.com/blog/1101843/202010/1101843-20201029091740174-1560674849.png

微 信

oracle 查询char类型的数据

曾经遇到一个坑。

select taskdate from taskinfo where taskdate='20180828';//使用PLSQL工具 能查出结果

偏偏在java代码里面查询不出结果。

select taskdate from taskinfo where taskdate='20180828  ';//给查询条件的值添加两个空格后就能查出结果

原因:

taskdate在oracle表里面的数据类型是CHAR(10),

在oracle里面CHAR的长度是固定的,

存储字符串“taskdate",对于CHAR(10),表示你存储的字符将占10个字节(包括2个空字符),在数据库中它是以空格占位的.

 

oracle 用trunc(date) 函数去掉时分秒,只保留日期

 

-----------------------------------------------------------------------------

 

posted @ 2018-08-28 16:25  huangwanlin  阅读(1173)  评论(2编辑  收藏  举报
Copyright 2012-2021 林云希科技有限责任公司