This document describes using a merge statement in SQL to synchronize data between two tables, Dept and Dept_Copy. It will update matching rows in Dept_Copy with data from Dept, and insert any rows from Dept that are not already in Dept_Copy, copying the deptno, dname, and loc columns from Dept to Dept_Copy.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
28 views2 pages
Chapter 06 Merge Statement
This document describes using a merge statement in SQL to synchronize data between two tables, Dept and Dept_Copy. It will update matching rows in Dept_Copy with data from Dept, and insert any rows from Dept that are not already in Dept_Copy, copying the deptno, dname, and loc columns from Dept to Dept_Copy.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLS, PDF, TXT or read online on Scribd
You are on page 1/ 2
Merge
Dept Dept_Copy
deptno dname loc deptno
10 ACCOUNTING Alex 10 20 RESEARCH DALLAS 20 30 SALES CHICAGO 30 40 OPERATIONS BOSTON 40 50 HR Port Said
Merge into dept_copy c
using dept d on ( c.deptno = d.deptno) when matched then update set c.dname=d.dname , c.loc=d.loc when not matched then insert values (d.deptno , d.dname , d.loc); Dept_Copy
dname loc ACCOUNTING NEW YORK RESEARCH DALLAS SALES CHICAGO OPERATIONS BOSTON