[23.03.08]

W·2023년 3월 8일
0

국비

목록 보기
119/119

SET UNUSED 옵션

  • SET UNUSED 옵션을 사용하여 하나 이상의 열을 unused로
    표시합니다.
  • DROP UNUSED COLUMNS 옵션을 사용하여 unused로 표시된
    열을 제거합니다.
  • ONLINE 키워드를 지정하여 열을 UNUSED로 표시하는 동안
    테이블에서 DML 작업이 허용됨을 나타낼 수 있습니다.

읽기 전용 테이블

  • ALTER TABLE 구문을 사용하여 다음을 수행할 수 있습니다.
  • 테이블을 읽기 전용 모드로 설정하여 테이블을 유지
    관리하는 동안 DDL 문 또는 DML 문에 의한 변경을
    방지합니다.
  • 테이블을 읽기/쓰기 모드로 다시 되돌립니다.

집합연산자 이용 예제

1번

select department_id
from departments
minus
select department_id
from employees
where job_id = 'ST_CLERK';

2번

select country_id, country_name
from countries
where country_id not in
(select country_id
from locations
where location_id in
(select location_id
from locations
INTERSECT
select location_id
from departments));
(선생님 풀이)
SELECT country_id,country_name 
FROM countries 
MINUS 
SELECT l.country_id,c.country_name 
FROM locations l JOIN countries c 
ON (l.country_id = c.country_id) 
JOIN departments d 
ON d.location_id=l.location_id;

3번

select job_id, department_id from employees
INTERSECT
select job_id, department_id from employees 
where 
department_id = 10 or
department_id = 20 or
department_id = 50;
(선생님 풀이)
SELECT distinct job_id, department_id 
FROM employees 
WHERE department_id = 10 
UNION ALL 
SELECT distinct job_id, department_id 
FROM employees 
WHERE department_id = 50 
UNION ALL 
SELECT distinct job_id, department_id 
FROM employees 
WHERE department_id = 20;

4번

select employee_id, job_id
from employees
intersect
select employee_id, job_id
from job_history;

5번

select last_name, department_id, null
from employees
union
select null, department_id, department_name
from departments;
(선생님 풀이)
SELECT last_name,department_id,TO_CHAR(null) 
FROM employees 
UNION 
SELECT TO_CHAR(null),department_id,department_name 
FROM departments;

0개의 댓글