계층형 쿼리.
SELECT DCODE as ah, DNAME, PDEPT as bumo, LEVEL
FROM DEPT2
START WITH DCODE = '0001'
CONNECT BY PRIOR DCODE = PDEPt and LEVEL <= 2;
SELECT lpad(' ', level *3, '-') || DCODE as ah, DNAME, PDEPT as bumo, LEVEL
FROM DEPT2
START WITH DCODE = '0001'
CONNECT BY PRIOR DCODE = PDEPT;
sELECT lpad(' ', (LEVEL-1)*3, ' ') || LAST_NAME,
employee_id,
MANAGER_ID,
LEVEL
FROM EMPLOYEES
START WITH employee_id = 101
CONNECT BY PRIOR employee_id = manager_id;
-- 얘 하나만 빼기.
SELECT lpad(' ', (LEVEL-1)*3, ' ') || LAST_NAME,
employee_id,
MANAGER_ID,
LEVEL
FROM EMPLOYEES
WHERE LAST_NAME != 'Greenberg'
START WITH employee_id = 101
CONNECT BY PRIOR employee_id = manager_id;
-- 가지치기.
SELECT lpad(' ', (LEVEL-1)*3, ' ') || LAST_NAME,
employee_id,
MANAGER_ID,
LEVEL
FROM EMPLOYEES
START WITH employee_id = 101
CONNECT BY PRIOR employee_id = manager_id and LAST_NAME != 'Greenberg';