在Oracle中左右连接省去了sql server中复杂的连接语句(left join ,right join),就用一个"(+)"表示。下面做了下实验:其中查询1和查询2是等同效果的,查询3和查询4是等同效果的。
查询1:
select first_name,department_name,emp.department_id from emp,departments dept
where emp.department_id(+)=dept.department_id;
122 rows selected.
查询2:
select first_name,department_name,emp.department_id from departments dept left join emp
on emp.department_id=dept.department_id;122 rows selected.
查询3:
select first_name,department_name,emp.department_id from emp,departments dept
where emp.department_id=dept.department_id(+);
107 rows selected.
查询4:
select first_name,department_name,emp.department_id from emp left join departments dept
on emp.department_id=dept.department_id;107 rows selected.
总结: 1,(+)在哪一边,则返回另一边所有的记录。
2,(+)放在包含空值的一边,不可以两边同时使用。
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12MySQL InnoDB存储引擎锁机制实验Oracle Database 10g Express Edition 最大连接数的修改方法相关资讯 Oracle连接 Oracle左右连接 Oracle左连接
- Oracle左连接、右连接、全外连接以 (今 14:06)
| - Oracle排序合并连接 (02/13/2013 14:47:46)
|
本文评论 查看全部评论 (0)