日期:2014-05-16  浏览次数:20443 次

oracle 外联接

oracle 外联接 “(+)” 的用法:

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 
Connected as scott

SQL> select deptno from dept;
 
DEPTNO
------
    10
    20
    30
    40
    50
 
SQL> select ename from emp;
 
ENAME
----------
SMITH
ALLEN
WARD
JONES
MARTIN
BLAKE
CLARK
SCOTT
KING
TURNER
ADAMS
JAMES
FORD
MILLER
 
14 rows selected
 
SQL> select d.deptno,e.ename from dept d,emp e where e.deptno(+)=d.deptno;
 
DEPTNO ENAME
------ ----------
    20 SMITH
    30 ALLEN
    30 WARD
    20 JONES
    30 MARTIN
    30 BLAKE
    10 CLARK
    20 SCOTT
    10 KING
    30 TURNER
    20 ADAMS
    30 JAMES
    20 FORD
    10 MILLER
    50 
    40 
 
16 rows selected
 
SQL> select d.deptno,e.ename from dept d,emp e where e.deptno=d.deptno(+);
 
DEPTNO ENAME
------ ----------
    20 SMITH
    30 ALLEN
    30 WARD
    20 JONES
    30 MARTIN
    30 BLAKE
    10 CLARK
    20 SCOTT
    10 KING
    30 TURNER
    20 ADAMS
    30 JAMES
    20 FORD
    10 MILLER
 
14 rows selected

?结果表示 “(+)” 出现在哪张表旁边,则那张表为补充表。