温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Oracle_071_lesson_p9

发布时间:2020-03-31 18:00:11 来源:网络 阅读:270 作者:TONY16168 栏目:关系型数据库

集合操作

Oracle_071_lesson_p9
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 括号可以更改执行优先级。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI