日期大于d.dt>sysdate作为或条件的一部分,将始终返回15条记录。要返回7条记录,它必须是和状态。您可以使用哪个版本和修补程序级别来复制它?嗨,Alex,我在Oracle 11r2版本中复制了它,安装在Windows 7 64位体系结构上。11.2
日期大于d.dt>sysdate作为或条件的一部分,将始终返回15条记录。要返回7条记录,它必须是和状态。您可以使用哪个版本和修补程序级别来复制它?嗨,Alex,我在Oracle 11r2版本中复制了它,安装在Windows 7 64位体系结构上。11.2,oracle,sysdate,Oracle,Sysdate,日期大于d.dt>sysdate作为或条件的一部分,将始终返回15条记录。要返回7条记录,它必须是和状态。您可以使用哪个版本和修补程序级别来复制它?嗨,Alex,我在Oracle 11r2版本中复制了它,安装在Windows 7 64位体系结构上。11.2.0.1,还是经过修补?在11.2.0.2(SQL Fiddle似乎正在运行)或更高版本上,它似乎不可复制。如果您处于更高的补丁级别,那么它可能是特定于操作系统的。真的很奇怪,这似乎是一个bug。这可能是一个非常关键的bug!我想知道,我也不能
日期大于
d.dt>sysdate
作为或
条件的一部分,将始终返回15条记录。要返回7条记录,它必须是和
状态。您可以使用哪个版本和修补程序级别来复制它?嗨,Alex,我在Oracle 11r2版本中复制了它,安装在Windows 7 64位体系结构上。11.2.0.1,还是经过修补?在11.2.0.2(SQL Fiddle似乎正在运行)或更高版本上,它似乎不可复制。如果您处于更高的补丁级别,那么它可能是特定于操作系统的。真的很奇怪,这似乎是一个bug。这可能是一个非常关键的bug!我想知道,我也不能复制!我的版本是Oracle数据库11g企业版11.2.0.2.0-64位Unix,Solaris
@San-感谢您的确认;正如我在一篇关于这个问题的评论中所说,我怀疑这可能是错误9495697,“对于在同一列上包含两个或多个筛选谓词的查询,可能会返回错误的结果,其中一个谓词的另一端不是编译时常量(例如,它是bind、sysdate等)”。
CREATE TABLE AAA ( DT DATE );
insert into aaa (DT) values (to_date('13-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('14-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('15-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('16-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('17-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('18-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('19-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('20-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('21-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('22-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('23-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('24-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('25-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('26-01-2013', 'dd-mm-yyyy'));
insert into aaa (DT) values (to_date('27-01-2013', 'dd-mm-yyyy'));
commit;
select count(*) from aaa d
where
(d.dt > sysdate)
or
d.dt < to_date(20130120,'yyyymmdd')
select count(*) from aaa d
where
d.dt < to_date(20130120,'yyyymmdd')
or
(d.dt > sysdate)
d.dt+1 > sysdate+1
SQL> host ver
Microsoft Windows [Version 6.1.7601]
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL>
SQL> select count(*)
2 from aaa d
3 where (d.dt > sysdate)
4 or d.dt < to_date('20130120','yyyymmdd')
5 /
COUNT(*)
----------
15
Execution Plan
----------------------------------------------------------
Plan hash value: 977873394
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 9 | | |
|* 2 | TABLE ACCESS FULL| AAA | 15 | 135 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("D"."DT" IS NOT NULL)
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
4 recursive calls
0 db block gets
15 consistent gets
0 physical reads
0 redo size
346 bytes sent via SQL*Net to client
364 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> ed
Wrote file afiedt.buf
1 select count(*)
2 from aaa d
3 where d.dt < to_date('20130120','yyyymmdd')
4* or (d.dt > sysdate)
SQL>
/
COUNT(*)
----------
7
Execution Plan
----------------------------------------------------------
Plan hash value: 977873394
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 9 | | |
|* 2 | TABLE ACCESS FULL| AAA | 7 | 63 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("D"."DT"<TO_DATE(' 2013-01-20 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') OR "D"."DT">SYSDATE@!)
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
4 recursive calls
0 db block gets
15 consistent gets
0 physical reads
0 redo size
346 bytes sent via SQL*Net to client
364 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
SQL> ed
Wrote file afiedt.buf
1 select count(*)
2 from aaa d
3 where (d.dt + 1 > sysdate + 1)
4* or d.dt < to_date('20130120','yyyymmdd')
SQL> /
COUNT(*)
----------
7
Execution Plan
----------------------------------------------------------
Plan hash value: 977873394
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 9 | 3 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 9 | | |
|* 2 | TABLE ACCESS FULL| AAA | 7 | 63 | 3 (0)| 00:00:01 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter("D"."DT"<TO_DATE(' 2013-01-20 00:00:00', 'syyyy-mm-dd
hh24:mi:ss') OR INTERNAL_FUNCTION("D"."DT")+1>SYSDATE@!+1)
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
5 recursive calls
0 db block gets
15 consistent gets
0 physical reads
0 redo size
346 bytes sent via SQL*Net to client
364 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>