在Oracle中,我要根据用户输入的起始日期和结束日期,查询用户数据。
以下两条 SQL 语句,查询结果一样吧?
请问,哪一条语句的执行效率更高?原理是什么?
(注:inure_time 是普通 date 型字段,没有索引,也没有分区)。
=============
语句1
select user_id, user_name from users
where to_char(inure_time,'yyyy-mm-dd') between '2005-11-02' and '2005-11-05'
=============
语句2
select user_id, user_name from users
where inure_time
  between to_date('2005-11-02 00:00:00', 'yyyy-mm-dd hh24:mi:ss') 
      and to_date('2005-11-05 23:59:59', 'yyyy-mm-dd hh24:mi:ss')