desc test
id number(10)
name varchar2(20)
date1 dateselect * from test where to_char(date1,'yyyymmdd')=20030828;

解决方案 »

  1.   

    where a=to_date('2003-08-28 16:00:00', 'yyyy-mm-dd hh24:mi:ss')
      

  2.   

    where a=to_date('2003-08-28 16:00:00', 'yyyy-mm-dd hh24:mi:ss')
      

  3.   

    不用to_char怎么办,这样速度很慢
      

  4.   

    to BlueskyWide(谈趣者) 
    一般不用你这种方法,因为date1字段还要做转换,如果date1有索引,
    这种转换不会使用到索引,除非建立了function indexed,不知道是否
    正确,请批评指教
      

  5.   

    select * from test where to_char(date1,'yyyymmdd')='20030828';
    楼上说的是用不上索引,主要能实现楼主的功能。
      

  6.   

    先索引a,
    再用where a between 时间1 and 时间2;试试
      

  7.   

    楼主已经说很清楚了,“不用to_char怎么办,这样速度很慢”
    那一定要建立索引了
      

  8.   

    函数索引代替:
    create index test_index on test(to_char(a,'yyyymmdd'));