gpt4 book ai didi

sql - Oracle 11.2.0.2.0 中的日期比较问题

转载 作者:行者123 更新时间:2023-12-04 06:04:32 26 4
gpt4 key购买 nike

我遇到过 Oracle DBMS 的奇怪行为。
用下面引用的 SQL 结果集是空的。如果我删除“this_.order_date >="条件之一 - 它返回预期的 2 行。

SELECT DISTINCT this_.id AS y0_,
this_.order_date AS y1_
FROM flight_trip_orders this_,
int_work_order_info iwoi1_,
state_history_records cs2_
WHERE this_.work_info_id =iwoi1_.id
AND iwoi1_.state_history_records_id=cs2_.id
AND this_.order_date <=to_timestamp('12/16/2011', 'mm/dd/yyyy')
AND this_.order_date >=to_timestamp('12/13/2011', 'mm/dd/yyyy')
AND this_.order_date >=to_timestamp('12/15/2011', 'mm/dd/yyyy')
AND rownum <=2;

这怎么会发生?在两个不同的 Oracle 实例上查询结果不同,但都是 11.2.0.2.0 版本

请不要建议优化查询和删除条件 - 查询已生成,我无权更改它。

编辑:
添加提示“ALL_ROWS”有助于解决此问题。问题是我不能在实际应用中添加这个提示,如上所述。

最佳答案

如果您对问题的描述准确无误,那么听起来可能是优化程序错误。也许冗余条件处理不当,导致使用了不正确的过滤器。我要做的第一件事是查看完整查询和没有“12/13/2011”条件的查询的执行计划,并寻找差异,特别是在应用的谓词中。

关于sql - Oracle 11.2.0.2.0 中的日期比较问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8520814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com