본문 바로가기

프로그래밍/ORACLE

[ORACLE] 조인으로 삭제하기

오라클 조인으로 데이터 삭제하기 샘플입니다.

DELETE 
  FROM EMP A 
 WHERE EXISTS ( 
               SELECT 1 
                 FROM DEPT B 
                WHERE A.DEPTNO = B.DEPTNO 
                  AND B.DEPTNO = '20' 
               ); 

DELETE 
  FROM EMP A 
 WHERE A.DEPTNO = ( 
                   SELECT B.DEPTNO 
                     FROM DEPT B 
                    WHERE A.DEPTNO = B.DEPTNO 
                      AND B.DEPTNO = '20' 
                   ); 
         
DELETE 
  FROM EMP A 
 WHERE (A.DEPTNO, A.ENAME) = ( 
                              SELECT B.DEPTNO, B.NAME 
                                FROM DEPT B 
                               WHERE B.DEPTNO = '20' 
                             );