2.在oracle的scott用户中有表emp select * from emp where deptno >= 20 union all select * from emp where deptno <= 30 这里的结果就有很多重复值了。
有关union和union all关键字需要注意的问题是:
union 和 union all都可以将多个结果集合并,而不仅仅是两个,你可以将多个结果集串起来。 使用union和union all必须保证各个select 集合的结果有相同个数的列,并且每个列的类型是一样的。但列名则不一定需要相同,oracle会将第一个结果的列名作为结果集的列名。例如下面是一个例子: select empno,ename from emp union select deptno,dname from dept 我们没有必要在每一个select结果集中使用
order by
子句来进行排序,我们可以在最后使用一条order by来对整个结果进行排序。例如: select empno,ename from emp union select deptno,dname from dept order by ename;