之前不是很常使用merge into这个方法,最近因为有需求,研究了了一下,留个记录方便以后自己再用。
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 [schema .] table [t_alias]
USING [schema .] { table | view | subquery } [t_alias]
ON ( condition )
WHEN MATCHED AND (condition ) THEN merge_update_clause
WHEN MATCHED THEN merge_update_clause
WHEN NOT MATCHED AND (condition )THEN merge_insert_clause
WHEN NOT MATCHED THEN merge_insert_clause;
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 [schema .] table [t_alias]
USING [schema .] { table | view | subquery } [t_alias]
ON ( condition )
WHEN MATCHED AND (condition ) THEN merge_update_clause
WHEN MATCHED THEN merge_update_clause
WHEN NOT MATCHED AND (condition )THEN merge_insert_clause
WHEN NOT MATCHED THEN merge_insert_clause;