Oracle的集合运算符有并集union、union all,交集intersect,差集minus

先建表myemp,进行集合运算的测试

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。
create table myemp as select * from emp where empno = 7934;

并集

union all不过滤掉集合中重复的数据

union过滤掉集合中重复的数据

1 select * from emp
2 union all
3 select * from myemp;
4 
5 select * from emp
6 union 
7 select * from myemp;

交集

返回两个集合中相同的数据组成新的查询结果

select * from emp
intersect
select * from myemp;

差集

返回集合1中独有而集合2中没有的数据组成新的查询结果

select * from emp
minus
select * from myemp;

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄