simplefrog

日期数据应该使用单引号扩起来. 字符数据大小写敏感, 日期数据格式敏感. 默认的日期格式是 DD-MON-RR.有日期需求时,日期可能格式多样,所以要做显示转换,不要隐式转换

 

Oracle的注册表配置,参数配置,会话配置都会带来日期格式的变化
SQL> select last_name,hire_date from employees where hire_date=\'07-6月 -94\';

更改会话设置后
SQL> alter session set nls_date_format=\'yyyy-mm-dd\';
SQL> select last_name,hire_date from employees where hire_date=\'07-6月 -94\';

解决方法做显式转换
where to_char(hire_date,’yyyy-mm-dd’)=’2011-9-11’但是这样做又会造成hire_date列上的索引失效
保证索引不失效的方法(提示: \'2011-9-10\'实际上是\'2011-9-10  0点0分0秒\')
where hire_date>=’2011-9-10’ and hire_date<’2011-9-11’

分类:

技术点:

相关文章:

  • 2021-09-06
  • 2021-07-16
  • 2021-08-14
  • 2022-01-19
  • 2022-12-23
  • 2021-11-27
  • 2021-11-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2022-01-03
  • 2022-12-23
  • 2021-05-14
  • 2021-10-16
  • 2021-05-30
相关资源
相似解决方案