merge into Target using Source
on (condition)
when matched then
update set column1=value1
when not matched then
insert (column1, column2) values (value1, value2);
解释:
Target : 目标表名
Source: 源表名
Condition: 为匹配条件
当matched时更新,not时则更新
本文介绍了一种使用SQL实现的数据同步方法,通过MERGE语句实现在目标表中匹配时更新记录,未匹配时插入新记录的功能。这种方法适用于批量数据处理场景,能够高效地保持两个数据集的一致性。
merge into Target using Source
on (condition)
when matched then
update set column1=value1
when not matched then
insert (column1, column2) values (value1, value2);
解释:
Target : 目标表名
Source: 源表名
Condition: 为匹配条件
当matched时更新,not时则更新
248
5420

被折叠的 条评论
为什么被折叠?