SCOTT@bys1>select deptno,dname as "aa",loc from dept union select deptno,dname,loc from dept;
DEPTNO aa LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
?2.Union All
SCOTT@bys1>select deptno,dname,loc as "aa" from dept union allselect deptno,dname,loc as "bb" from dept;
DEPTNO DNAME aa
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
?3.intersect
SCOTT@bys1>select deptno,dname,loc as "aa" from dept intersect select deptno,dname,loc as "bb" from dept;
DEPTNO DNAME aa
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
?4.minus
SCOTT@bys1>select deptno,dname,loc as "aa" from dept minus select deptno,dname,loc as "bb" from dept; no rows selected
Oracle中union/union all/Intersect/Minus用法
原文:http://changbl.iteye.com/blog/2303117