여러개의 select 문을 하나의 쿼리로 만드는 연산자
조건: 각 쿼리의 컬럼 개수와 데이터 타입이 일치
[1] 사원 테이블에서 급여가 3000이상인 사원의직업과 부서번호 조회
select job,dno
from employee
where salary >=3000;--결과 : 중복 포함 3개(analyist,20이 중복)
[2] 사원테이블에서 부서번호가 10인 사원의 직업과 부서번호 조회
select job,dno
from employee
where dno=10;--결과 : 3개 ROW
UNION : 중복을 제거하고 두 집합 반환
select job,dno
from employee
where salary >=3000
UNION
select job,dno
from employee
where dno=10;-- 4개의 ROW
UNION ALL: 중복을 제거하지 않고 두 집합 반환
select job,dno
from employee
where salary >=3000
UNION all
select job,dno
from employee
where dno=10;--결과6개의 row
INTERSECT:각 쿼리의 결과 중 '같은 결과만 반환'하는 '교집합'
select job,dno
from employee
where salary >=3000
INTERSECT
select job,dno
from employee
where dno=10;--(president,10)
MINUS: 앞 쿼리의 결과 - 뒤 쿼리의 결과 ('차집합')(중복제거) 쿼리 순서 중요
select job,dno
from employee
where salary >=3000
MINUS
select job,dno
from employee
where dno=10;
'DB > 오라클' 카테고리의 다른 글
[ORACLE]뷰,뷰옵션 (0) | 2022.08.18 |
---|---|
[ORACLE]제약조건 변경 + ON DELETE (0) | 2022.08.12 |
[ORACLE]데이터 무결성과 제약조건 (0) | 2022.07.24 |
[ORACLE]DML(INSERT,UPDATE,DELETE) (0) | 2022.07.21 |
[ORACLE]데이터사전 (0) | 2022.07.19 |