集合操作UNION、UNION ALL、INTERSECT、MINUS区别
来源:互联网 发布:帝国cms 附件名称 编辑:程序博客网 时间:2024/05/16 07:29
有两个表job_history表有10条数据;employees表有107条数据,这两个表有2条数据是重复的
SQL> ed
已写入 file afiedt.buf
1 SELECT employee_id id, job_id
2 FROM employees
3 minus
4 SELECT employee_id id, job_id
5* FROM job_history
SQL> /
表示返回在employees中存在,而不在job_history中的记录,返回105条数据,去掉了2条重复的数据
SQL> ed
已写入 file afiedt.buf
1 SELECT employee_id id, job_id
2 FROM job_history
3 minus
4 SELECT employee_id id, job_id
5* FROM employees
SQL> /
表示返回在job_history中存在,而不在employees中的记录,返回8条数据,去掉了2条重复的数据
集合操作中的ORDER BY子句
只能在整个集合的最后出现.可以按照第一个SELECT语句中的列名, 别名或者位置号排序.
SQL> ed
已写入 file afiedt.buf
1 SELECT employee_id id, job_id
2 FROM employees
3 UNION all
4 SELECT employee_id, job_id
5 FROM job_history
6* order by employee_id
SQL> /
下面的语句是正确的
SQL> ed
已写入 file afiedt.buf
1 SELECT employee_id, job_id
2 FROM employees
3 UNION all
4 SELECT employee_id id, job_id
5 FROM job_history
6* order by employee_id
SQL> /
小结
在SELECT 列表中的表达是必须有同样的数目和类型.
在结果中显示第一个Select语句中的列名.
除了 UNION ALL操作外,其他的集合操作都自动去掉重复值.
所以其他操作会隐式的进行排序操作(sql语句中并没有order by),使用CPU资源.
除了UNION ALL操作外,其他集合操作的输出结果默认按照升序的次序排列 .
所以其他操作会隐式的进行排序操作(sql语句中并没有order by),使用CPU资源.
- 集合操作,union,union all,intersect, minus
- 集合操作UNION、UNION ALL、INTERSECT、MINUS区别
- Oracle集合操作符union、union all、intersect和minus
- Oracle集合操作函数:Union、Union All、Intersect、Minus
- 集合操作符 Union / Union All / Intersect / Minus
- union union all intersect minus 集合
- oracle集合union、union all、intersect、minus
- union union all intersect minus 集合
- 集合运算(UNION、UNION ALL、INTERSECT、MINUS)
- Oracle Union/Union All/Intersect/Minus区别
- Union, Union all, intersect, minus
- union、union all、intersect、minus
- Union、Union All、Intersect、Minus
- UNION ,UNION ALL ,INTERSECT ,MINUS
- Oracle集合函数:Union、Union All、Intersect、Minus等
- ORACLE集合操作符号UNION、UNION ALL、INTERSECT、MINUS来进行查询结果的合并操作
- Oracle 集合操作函数:union、intersect、minus
- Oracle集合操作函数:union、intersect、minus
- CFinder
- Android从相册、照相机选择图片(支持4.4+,KIKAT以上)
- Unity2d 骨骼动画1:介绍
- 开发人员注意了,现在有很多IT企业的公司不讲信用
- 找完数
- 集合操作UNION、UNION ALL、INTERSECT、MINUS区别
- 自定义AlertDialog(仿微信)
- 关于Firefox和IE在CSS样式表中的差异解决方案
- ServletConfig理解
- struts2标签--form中的theme属性
- 学习计算机专业知识,我们该学什么?
- rmi object areald export
- 201 Bitwise AND of Numbers Range
- 利用gitolite实现自动部署的简易实现方式