在 Oracle 中,关于语法——如何将 (+) 语法转换为现代常规 JOIN?

In Oracle, in regards to syntax - how do I convert the (+) syntax to modern conventional JOIN?

假设我有一个像这样的 FROM 子句:

  FROM 

      apps.po_requisition_lines_all prl,  
      apps.po_requisition_headers_all prha,  
      po.po_req_distributions_all prda,  
      po.po_distributions_all pda,  
      po.po_headers_all pha 
  where 1=1  
      and prl.requisition_header_id= prha.requisition_header_id 
      and prl.requisition_line_id= prda.requisition_line_id 
      and prda.distribution_id= pda.req_distribution_id(+) 
      and pha.po_header_id(+)=pda.po_header_id 

那么如果我们想使用普通的JOIN语法,那么这种类型的OUTER JOIN如何转换呢?谢谢!

在没有看到模式的情况下,我觉得很难,但这应该让你朝着正确的方向前进:

 FROM apps.po_requisition_lines_all prl 
 INNER JOIN apps.po_requisition_headers_all prha ON prl.requisition_header_id = prha.requisition_header_id 
 INNER JOIN po.po_req_distributions_all     prda ON prda.requisition_line_id  = prl.requisition_line_id
 LEFT  JOIN po.po_distributions_all         pda  ON prda.distribution_id      = pda.req_distribution_id 
-- I note from the example provided that this is a right join
-- Without seeing the schema, it looks to me as though it should be left
-- As I say say, without seeing the schema, I probably shouldn't pass comment
 RIGHT JOIN po.po_headers_all               pha  ON pha.po_header_id          = pda.po_header_id;

对于 INNER JOIN 你可以只说 JOIN 虽然我认为明确地说 INNER 有助于提高可读性。我还注意到提供的示例有 WHERE 1=1,这是多余的。

+Outer Joins的旧版本,与[=33不同=]+出现在等号之后或之前,但是现在建议使用Join关键字而不是+,关于+ 来了就签:

=之后:

select * from t1, t2
where t1.id=t2.id(+)

这意味着左外连接:

select * from t1
left outer join t2 on t1.id=t2.id

之前=:

select * from t1, t2
where t1.id(+)=t2.id

这意味着右外连接:

select * from t1
Right outer join t2 on t1.id=t2.id

没有+:

select * from t1, t2
where t1.id=t2.id

这意味着内连接:

select * from t1
join t2 on t1.id=t2.id