一、union求并集,公共部分只有包含一次
例:求emp表ename中含’A‘或含有‘M’
SQL> select * from emp where ename like '%A%'
2 union
3 select * from emp where ename like '%M%';
二、union all求集并,公共部分只有包含二次
例:求emp表ename中含’A‘或含有‘M’
SQL> select * from emp where ename like '%A%'
2 union all
3 select * from emp where ename like '%M%';
三、intersect求交集,只有包含公共部分
例:求emp表ename中即含’A‘又含有‘M’
SQL> select * from emp where ename like '%A%'
intersect
select * from emp where ename like '%M%';
四、minus求差集,求集合A去除集合A和集合B的交集
例:求emp表sal从700到1200
SQL>select * from emp where sal between 700 and 1300
minus
select * from emp where sal between 1200 and 1400;
例:求emp表ename中含’A‘或含有‘M’
SQL> select * from emp where ename like '%A%'
2 union
3 select * from emp where ename like '%M%';
二、union all求集并,公共部分只有包含二次
例:求emp表ename中含’A‘或含有‘M’
SQL> select * from emp where ename like '%A%'
2 union all
3 select * from emp where ename like '%M%';
三、intersect求交集,只有包含公共部分
例:求emp表ename中即含’A‘又含有‘M’
SQL> select * from emp where ename like '%A%'
intersect
select * from emp where ename like '%M%';
四、minus求差集,求集合A去除集合A和集合B的交集
例:求emp表sal从700到1200
SQL>select * from emp where sal between 700 and 1300
minus
select * from emp where sal between 1200 and 1400;