下面两次查询表,用不同的sql相同的逻辑(就是在theday限制稍有差别),但是查出来结果确是不一样的
已经可以确定表的数据没有变化(theday的类型是NUMBER(8) 表里面userid肯定有索引 theday似乎也有)
请问
有什么情况会导致出现这种奇怪的事情呢select /*+parallel (a, 4)*/ eboxid,amt,souce,month,theday from chglog a where SOUCE in(0,1) and userid=5912114 and theday=20101001;AMT SOUCE MONTH THEDAY
--- ----- ------------ ----------
39  1     20101000     20101001  
30  1     20101000     20101001  2 rows selected.
==================================
select /*+parallel (a, 4)*/ eboxid,amt,souce,month,theday from chglog a where SOUCE in(0,1) and userid=5912114 and theday like '20101001%';AMT  SOUCE MONTH THEDAY
---- ----- ------------ ----------
1700 0     20100900     20101001  
833  0     20100900     20101001  
39   1     20101000     20101001  
30   1     20101000     20101001  4 rows selected.============
应该不是并行的影响,我去掉并行查出来结果也一样

解决方案 »

  1.   

    1700 0 20100900 20101001   
    833 0 20100900 20101001   
    这两条纪录里的20101001 可能含有空格--这样看看结果是什么
    select /*+parallel (a, 4)*/ eboxid,amt,souce,month,theday from chglog a where SOUCE in(0,1) and userid=5912114 and trim(theday)=20101001;
      

  2.   

    看不出原因,
    一般出现这种情况都是由于存在空格,或者事务的读写不一致导致的,
    也就是说其他session会话在你两次操作之间改变了表里数据你真的能确定表中数据没有变化?
    其他session会不会insert了SOUCE=0 的两条数据呢?
      

  3.   

    嗯  应为多次不同时间段实验都返回相同结果 所以不可能有这么巧的session 可以认为不是数据修改的影响由于表结构是number(8) 理论上也不存在空格(或者是number也能插入空格? 不知道有没有这种情况)
    我甚至有怀疑是不是索引导致的,因为如果theday有索引 两个查询肯定是一个用上索引 另一个用不上但是网上又找不到说索引会影响查询结果的说法 更不知道如果是这种情况怎么解决
      

  4.   

    --这个语句的执行结果是多少?
    select /*+parallel (a, 4)*/ eboxid,amt,souce,month,theday 
    from chglog a 
    where SOUCE in(0,1) and userid=5912114 and trim(theday)=20101001;
      

  5.   

    select /*+parallel (a, 4)*/ amt,souce,month,theday, length(theday) from chglog  a where SOUCE in(0,1) and userid=5912114 and trim(theday) = 20101001;
    AMT  SOUCE MONTH THEDAY LENGTH(THEDAY
    ---- ----- ------------ ---------- ---------------
    1700 0     20100900     20101001   8              
    833  0     20100900     20101001   8              
    39   1     20101000     20101001   8              
    30   1     20101000     20101001   8    
      

  6.   

    trim(theday) 这个就是消除theday中的空格 说明还是有空格的嘛
      

  7.   

    这个结论估计不成立
    1 length返回8 并且字段是number(8)类型
    2 我特意圈选了一下 20101001后面是没有字符的
      

  8.   

    你的这个theday字段是自动从时间的记录转过来的还是直接手动插入的
      

  9.   

    两个sql是使用什么工具执行的?
      

  10.   

    不知道  我只负责从这张表取数 插数是其它人负责的我估计是通过绑定变量输入的sql用sqlplus执行过 结果一样用我们自己开发的一个小工具(oci)查出来结果也一样应该跟工具无关