Oasis' story

DML (Data Manipulating Language 데이터 조작어) 본문

Program Note/DB

DML (Data Manipulating Language 데이터 조작어)

oasispapa 2014. 10. 10. 17:27

* INSERT :

       ex) subquery 이용한 insert

       INSERT INTO (SELECT column1, deptno FROM emp WHERE deptno='20' WITH CHECK OPTION)

              VALUES (column1, '10' FROM emp) -- 요롬 에러남. 체크 옵션에 걸려서.

 

* UPDATE

* DELETE

* MERGE (9i 부터 가능) : 해당 행이 존재 할 경우, update, 새로운 행이면 insert 수행

       ex) MERGE INTO talble_name A

                         USING (table_name2) B

                        ON A.column1 = B.column2

                   WHEN MATCHED THEN

                        UPDATE SET col1 = '111'

                                           ,col2 = '222'

                        DELETE WHERE (10g부터 사용가능)

                    WHEN NOT MATCHED THEN

                        INSERT (col1, col2)

                        VALUES ('111','222')