ORACLE UNION

UNION:union 排序;集合的并,不包含重复行
UNION ALL:union all 不排序;集合的并,包含重复行
UNION / UNION ALL:忽略UNION / UNION ALL后面的别名
例如:
SELECT department_id "DEPT_ID", department_name,'b'
FROM departments
WHERE department_id=90
UNION ALL
SELECT department_id, department_name "DEPT_NAME", 'a'
FROM departments
WHERE department_id=10
结果:    
DEPT_ID DEPARTMENT_NAME 'B'
1 90 Executive b
2 10 Administration a
intersect:集合的交,不包含重复行
minus:集合的差,不包含重复行

Comments

Popular posts from this blog

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation

ORACLE Error