sql语句里面的集合运算:
union all:将第一个语句的结果和第二个语句的结果,拼接在一起
select job from scott.emp where deptno=10
union all
select job from scott.emp where deptno=20;,
结果相同
select job from scott.emp where deptno=10 or deptno=20;
union:将第一个语句的结果和第二个语句的结果,拼接在一起,并且去除掉重复的数据
select job from scott.emp where deptno=10
union
select job from scott.emp where deptno=20;
结果相同
select distinct job from scott.emp where deptno=10 or deptno=20;
minus:显示第一个语句有的内容,但是第二个句子没有的内容
select job from scott.emp where deptno=20
minus
select job from scott.emp where deptno=10;
intersect:显示两个句子共有的数据部分
select job from scott.emp where deptno=20
intersect
select job from scott.emp where deptno=10;
union all和union有什么区别?
union all是拼接所有的数据,union也是拼接所有的数据,但是会对数据做去重的处理;
union all的效率更高,通常会使用union all替代or的语句。
759

被折叠的 条评论
为什么被折叠?



