标签:style class ext color width c
数据表的连接有: 
1、内连接(自然连接): 
inner只有两个表相匹配的行才能在结果集中出现 
2、外连接: 包括 
(1)左外连接(左边的表不加限制) 
(2)右外连接(右边的表不加限制) 
(3)全外连接(左右两表都不加限制) 
3、自连接(连接发生在一张基表内) 
select a.studentno, 
a.studentname, b.classname 
  from students a, classes b 
  where a.classid(+) = 
b.classid; 
STUDENTNO 
STUDENTNAM CLASSNAME 
---------- 
---------- ------------------------------ 
  
  1 A     一年级一班 
  
  2 B     一年级二班 
  
          一年级三班 
以上语句是右连接: 
即"(+)"所在位置的另一侧为连接的方向,右连接说明等号右侧的所有 
记录均会被显示,无论其在左侧是否得到匹配。也就是说上例中,无 
论会不会出现某个班级没有一个学生的情况,这个班级的名字都会在 
查询结构中出现。 
反之: 
select a.studentno, 
a.studentname, b.classname 
  from students a, classes b 
  where a.classid = b.classid(+); 
STUDENTNO STUDENTNAM CLASSNAME 
---------- ---------- 
------------------------------ 
  
  1 A     一年级一班 
  
  2 B     一年级二班 
  
  3 C 
则是左连接,无论这个学生有没有一个能在一个班级中得到匹配的部门号, 
这个学生的记录都会被显示。 
select 
a.studentno, a.studentname, b.classname 
  
from students a, classes b 
  where a.classid = b.classid; 
这个则是通常用到的内连接,显示两表都符合条件的记录 
总之, 
左连接显示左边全部的和右边与左边相同的 
右连接显示右边全部的和左边与右边相同的 
内连接是只显示满足条件的! 
在Oracle PL-SQL中,左连接和右连接以如下方式来实现
标签:style class ext color width c
原文地址:http://www.cnblogs.com/colmeluna/p/3709340.html