/*Merge into 详细介绍
MERGE语句是Oracle9i新增的语法,用来合并UPDATE和INSERT语句。
通过MERGE语句,根据一张表或子查询的连接条件对另外一张表进行查询,
连接条件匹配上的进行UPDATE,无法匹配的执行INSERT。
这个语法仅需要一次全表扫描就完成了全部工作,执行效率要高于INSERT+UPDATE。
*/
/*语法:
MERGE [INTO [schema .] table [t_alias]
USING [schema .] { table | view | subquery } [t_alias]
ON ( condition )
WHEN MATCHED THEN merge_update_clause
WHEN NOT MATCHED THEN merge_insert_clause;
*/
merge into users using doctor on (users.user_id = doctor.doctorid) when matched then update set users.user_name = doctor.doctorname when not matched then insert values (doctor.doctorid, doctor.doctorid, '8736F1C243E3B14941A59FF736E1B5A8', doctor.doctorname, sysdate, 'T', ' ', doctor.deptid, 'b319dac7-2c5c-496a-bc36-7f3e1cc066b8');