merge into table t
using (select 'key' key from dual ) t2
on (t2.key = t.key)
when matched then
update set t.x = xxx, t.y = yyy,t.date = to_date(?, 'yyyy-mm-dd hh24:mi:ss')
when not matched then
insert (t.key,t.x, t.y) values ('key',xxx, yyy,)
如果数据存在则更新,否则执行插入
本文介绍了一种使用SQL的merge语句来实现数据的合并及更新操作的方法。当目标表中存在相同键值的数据时,将执行更新操作;若不存在,则执行插入操作。此方法有效地提升了数据处理效率。
1335

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



