您的位置:首页 > 数据库

sql merge的用法实例(学习日记)

2011-06-09 16:53 99 查看
merge我理解的意思就是根据on的判断来执行Insert还是update

merge into mytable as my ----mytable主表
using cy_contract as cy ---cy_contract 引用的表
on my.id = cy.ctid ----两张表的关系或者条件
when matched then ----如果满足
update set name = cy.ctname ----- 执行update
when not matched then ---否则
insert (name) values (cy.ctname); ------执行insert
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: