merge into emp01 t using emp02 f on ( t.emp_id = f.emp_id )when matched then update set t.dept_id = f.dept_id, t.job_id = f.job_id, t.first_name = f.first_name, t.last_name = f.last_name, t.salary = f.salarywhen not matched then insert ( emp_id, dept_id, job_id, first_name, last_name, salary) values ( f.emp_id, f.dept_id, f.job_id, f.first_name, f.last_name, f.salary)主要看ON條件,匹配和不匹配。using 後面的就是資料來源,支援子查詢。
merge into emp01 t using emp02 f on ( t.emp_id = f.emp_id )when matched then update set t.dept_id = f.dept_id, t.job_id = f.job_id, t.first_name = f.first_name, t.last_name = f.last_name, t.salary = f.salarywhen not matched then insert ( emp_id, dept_id, job_id, first_name, last_name, salary) values ( f.emp_id, f.dept_id, f.job_id, f.first_name, f.last_name, f.salary)主要看ON條件,匹配和不匹配。using 後面的就是資料來源,支援子查詢。