728x90

Programming/SQLP 3

배치 프로그램 튜닝 방법

1) 스칼라 서브쿼리를 이용한 조인 Select d.deptno, d.dname, (select sum(sal) from emp where deptno = d.deptno) sum_sal, (select max(sal) from emp where deptno = d.deptno) max_sal From dept d ▶ 스칼라 서브쿼리로 동일 테이블 여러 번 읽을 경우 아래와 같이 변경 합니다 Select d.deptno, d.dname, To_number(substr(sal,1,7)) sum_sal, To_number(substr(sql, 8,7)) max_sal From ( Select d.deptno, d.dname, (select lpad(sum(sal),7)||lpad(max(sal),7) fro..

Programming/SQLP 2023.05.04

Merge문

into절 갱신 or 삽입할 타깃 테이블 using절 갱신 or 삽입에 사용할 소스 테이블 on 갱신 or 삽일을 결정하는 조건 merge update 조건을 만족 하는 경우 수행 merge insert 조건을 만족하지 않는 경우 수행 Merge into target_table using source_table on ( 조건) when matched then -- update 절 update set column = , column = ... where 조건 [ delete -- 10.1 version부서 merge update절에 delete 기술(update절로 갱신된 행을 대상으로 수행) where 조건 ] -- 갱신된 값을 기준으로 행을 삭제. when not matched then -- inser..

Programming/SQLP 2021.04.20
728x90