【问题标题】:Oracle sql - what does (+) represent here [duplicate]Oracle sql-(+)在这里代表什么[重复]
【发布时间】:2018-05-19 19:30:18
【问题描述】:

我知道 (+) 可以用来表示 oracle sql 中的外连接。 这段代码中的 (+) 是什么意思?

where sysdate between start_date(+) and end_date(+) 

【问题讨论】:

  • 这意味着查询的编写者使用的是古老的 JOIN 语法,应该学习如何使用正确的、显式的 JOIN,尤其是外连接。
  • 如果它仍然受到 Oracle 的支持,它怎么会过时? (笑话)但是它是专有的和非标准的,没有理由使用它,因为 Oracle 现在已经支持标准的 OUTER JOIN 语法很多年了。
  • 我学习的那个人刚刚离开我的公司,他非常喜欢使用+。非常感谢这个社区的帮助。我不认为这是一个重复的问题,将其作为一个独立的问题可能会帮助像我这样的其他新手寻找解决方案。
  • @BillKarwin,(至少)有一个例外:当您想使用 FAST REFRESH 创建 MATERIALIZED VIEW 时,您必须使用旧的 Oracle 样式进行连接。 Oracle 认为这是“缺乏文档”——而不是错误!我不知道这种行为在最新的 Oracle 版本(即 12.2)中是否发生了变化
  • @WernfriedDomscheit,我继续对 Oracle 感到失望。

标签: sql oracle


【解决方案1】:

它允许外连接“生存” where 子句条件。即它还允许返回 NULL。例如下面

select *
from from_table ft, outer_table ot
where sysdate between ot.start_date(+) and ot.end_date(+) 
and ft.id = ot.ft_fk(+)

一个等价的可能是:

select *
from from_table ft
left join outer_table ot on ft.id = ot.ft_fk and sysdate between ot.start_date and ot.end_date

或者,它的等价物可能是:

select *
from from_table ft
left join outer_table ot on ft.id = ot.ft_fk
where (sysdate between ot.start_date and ot.end_date OR ot.start_date IS NULL)

【讨论】:

  • 太棒了!感谢您的帮助!
猜你喜欢
  • 2021-10-10
  • 1970-01-01
  • 2017-03-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-22
  • 1970-01-01
  • 2016-08-02
相关资源
最近更新 更多