Oracle数据库联接vs FROM a,b,c [英] Oracle db Joins vs FROM a,b,c

查看:273
本文介绍了Oracle数据库联接vs FROM a,b,c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用SQL Server db已有一段时间了,在那里我会 在我的查询中在任何地方加入表格.

I've been working with SQL Server db for some time, and there I would join the tables here and there and everywhere in my queries.

现在我有一个使用Oracle db的项目,并且在浏览过程中 一些oracle程序员编写的程序, complex 数据选择 查询中,我注意到她从不从未使用过联接.

Now I have a project with Oracle db, and as I looked through procedures some oracle programmer wrote, complex data selection query, I noticed she never ever used a join.

问题:

关于Oracle是否有任何特定内容暗示不使用联接或其人为因素?

Is there anything specific about Oracle that implies not using joins, or its human factor ?

推荐答案

否.与其他任何合理的关系数据库一样,Oracle在进行基于集合的操作和联接时比在过程上模拟联接(例如,嵌套的游标循环)时效率更高.

No. Oracle, like any other reasonable relational database, is more efficient when you do set-based operations and when you do joins rather than procedurally emulating joins (with, say, nested cursor loops).

但是,我的猜测是,您并不是在真正在谈论缺少联接的代码.我的猜测是,您正在谈论的代码使用的连接语法与您习惯的不同.两者

My guess, however, is that you are not really talking about code that lacks joins. My guess is that you are talking about code that uses a different join syntax than you are accustomed to. Both

SELECT a.*
  FROM a
       JOIN b ON (a.a_id = b.a_id)
       JOIN c ON (b.b_id = c.b_id)

SELECT a.*
  FROM a,
       b,
       c
 WHERE a.a_id = b.a_id
   AND b.b_id = c.b_id

是将abc的查询.这两个查询完全相同-Oracle解析器实际上将内部将第一个查询重写为第二个查询.唯一的不同是,第一个查询使用更新的SQL 99语法来指定其联接.

are queries that join a to b to c. The two queries are exactly identical-- the Oracle parser will actually internally rewrite the first query into the second. The only difference is that the first query uses the newer SQL 99 syntax to specify its joins.

从历史上看,Oracle采用SQL 99语法的时间相对较晚,在使用SQL 99语法之前编写了大量的代码,并且相当多的Oracle员工出于习惯而不喜欢旧样式的语法(如果没有的话)别的.由于所有这些原因,仅使用较旧的联接语法来查找基于Oracle的项目是相对普遍的.内在没有什么错(尽管我个人更喜欢较新的语法).

Historically, Oracle was relatively late to adopt the SQL 99 syntax, there is a tremendous amount of code that was written before the SQL 99 syntax was available, and quite a few Oracle folks prefer the old style syntax out of habit if nothing else. For all those reasons, it's relatively common to find Oracle based projects using the older join syntax exclusively. There is nothing inherently wrong with that (though I personally prefer the newer syntax).

这篇关于Oracle数据库联接vs FROM a,b,c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆