加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Oracle_071_lesson_p9

发布时间:2020-12-12 13:28:11 所属栏目:百科 来源:网络整理
导读:集合操作 UNION 及 UNION ALL UNION :列名,数据类型要一致,结果会默认ASC自动排序 UNION ALL :结果不会去重,不排序,其他和UNION一样 用类似to_char(null),to_number(null),to_date(null) 来填充缺列的情况; 如: select job_id from employees UNION
集合操作


UNION 及 UNION ALL
UNION :列名,数据类型要一致,结果会默认ASC自动排序
UNION ALL :结果不会去重,不排序,其他和UNION一样
用类似to_char(null),to_number(null),to_date(null) 来填充缺列的情况;
如:
select job_id
from employees
UNION
select job_id
from retired_employees

如:
select job_id,department_id
from employees
UNION ALL
select job_id,department_id
from retired_employees
order by job_id;

intersect 取交集
结果会排序,会去重
如:
select manager_id,department_id
from employees
INTERSECT
select manager_id,department_id
from retired_employees;

MINUS 前select的结果减去和后select的去重复的结果
如:
select employee_id,job_id
from employees
where department_id=80
MINUS
select employee_id,job_id
from retired_employees
where department_id=90

以上4种输出结果都只关心第1条select的定义order by 只能放在最后,且只能出现1次,且不能放在子查询里。parenthes 括号可以更改执行优先级。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读