集合操作符
UNION/UNION ALL
INTERSECT
MINUS

Union All不排序,不去重,其余均升序且去重。
create table e1 as select * from emp where deptno in (10,20);
create table e2 as select * from emp where deptno in (20,30);

select * from e1 union select * from e2 order by 8
select * from e1 union all select * from e2 order by 8
select * from e1 intersect select * from e2 order by 1 desc
select * from e1 minus select * from e2 order by 1 desc

SELECT location_id, department_name "Department",
TO_CHAR(NULL) "Warehouse location"
FROM departments
UNION
SELECT location_id, TO_CHAR(NULL) "Department",
state_province
FROM locations;

SELECT employee_id, job_id,salary
FROM employees
UNION
SELECT employee_id, job_id,0
FROM job_history;

posted on 2013-11-03 11:55  逝者如斯(乎)  阅读(304)  评论(0编辑  收藏  举报