oracle中有没有什么函数来代替半开闭时间区间  
例如:strTime>='2010-10-10' and strTime<'2010-10-20' 由于这种操作速度很慢!小妹在线等,谢谢!

解决方案 »

  1.   

    select * from tb1 where strTime between to_date('2010-10-10', 'yyyy-MM-dd') and to_date('2010-10-20', 'yyyy-MM-dd') 
      

  2.   

    '2010-10-10' 改成
    to_date('2010-10-10', 'yyyy-MM-dd')
      

  3.   

    strTime>=to_date('2010-10-10', 'yyyy-mm-dd') and strTime<to_date('2010-10-20', 'yyyy-mm-dd')
      

  4.   


    select * from tb1 where strTime between to_date('2010-10-10', 'yyyy-MM-dd') and (to_date('2010-10-20', 'yyyy-MM-dd')-1)
      

  5.   

    呵呵这个不对,刚刚那个是好的,between原本是半分的:包括10号但是不包括20号的
      

  6.   


    strTime>=to_date('2010-10-10', 'yyyy-mm-dd') and strTime<to_date('2010-10-20', 'yyyy-mm-dd')试试这样可以
      

  7.   

    select * from tb1 where strTime between to_date('2010-10-10', 'yyyy-MM-dd') and to_date('2010-10-19', 'yyyy-MM-dd')
      

  8.   

    strTime>='2010-10-10' and strTime<'2010-10-20',语句没错呀~
    如果仅仅是时间慢的话,不妨在strTime字段上建索引试试看!
      

  9.   

    应该是:
    strTime>=date'2010-10-10' and strTime < date'2010-10-20'
      

  10.   


      注意看下后面的一个日期-1天了    如果是传的参数  前一个是包括本身  但是后面一个时间-1天了 <20就是<=19 
      

  11.   

    没有那种函数,只能用>= and <来判断,效率不高就想办法加索引提高效率好了。
      

  12.   

    strTime>='2010-10-10' and strTime<'2010-10-20' 如果strTime和strTime是date类型则oracle不会使用索引。
      

  13.   

    最快的办法是加上索引。查询完了再吧索引drop掉!哈哈
      

  14.   

    to_date() 函数将字符串转换成时间类型
    如果你的strTime是时间类型,你则需要将设定的字符串转换成时间类型,如果有索引则可以正常使用。
    如果你的strTime是字符串类型,索引生成的索引可能就有问题,是不是使用索引oracle会根据你使用的RBO还是CBO来确定。
    你的需求下面的是SQL是正确的,前提是strTime是date类型,你可以在strTime上见索引来提高查询速度strTime>=to_date('2010-10-10', 'yyyy-mm-dd') and strTime<to_date('2010-10-20', 'yyyy-mm-dd')下面的前提是strTime是字符串类型,你建立索引有可能会用不到,这根据你的优化器选择的类型有关strTime>='2010-10-10' and strTime<'2010-10-20'