查看: 661|回复: 1

MERGE语法

 关闭 [复制链接]

签到天数: 2623 天

连续签到: 2 天

[LV.Master]至尊海神IIIIII

发表于 2010-10-31 10:41 |广东| 显示全部楼层 |阅读模式
MERGE语法   


WHEN MATCHED THEN
UPDATE SET column = { expr | DEFAULT }
           [, column = { expr | DEFAULT } ]...
[ where_clause ]
[ DELETE where_clause ]

在语法中DELETE 之前不常用,ORACLE解释为:

Specify the DELETE where_clause to clean up data in a table while populating or updating it. The only rows affected by this clause are those rows in the destination table that are updated by the merge operation. That is, the DELETE WHERE condition evaluates the updated value, not the original value that was evaluated by the UPDATE SET ... WHERE condition. If a row of the destination table meets the DELETE condition but is not included in the join defined by the ON clause, then it is not deleted. Any delete triggers defined on the target table will be activated for each row deletion.

使用delete where_clause 处理的数据是目标表中被merge 操作更新后数据,也就是被update set 更新后的数据,

即:以下数据将被删除:

1、符合ON条件。

2、被update 更新后符合delete where 条件的数据。




PCOS系统下载站:http://zhuangji.wang

签到天数: 322 天

连续签到: 0 天

[LV.8]威海将军I

发表于 2010-10-31 10:58 |福建| 显示全部楼层
学习一下哈
PCOS系统下载站:http://zhuangji.wang
回复 支持 反对

使用道具 举报

本版积分规则