从临时表更新到原始表



我有两个表,一个是原始表,另一个是临时表。具有正确记录的临时表。唯一列为cust_id。我的表格结构是

客户表

cust_id  amount
12       100
13       120
14       130
15       250
20        70
25       110
28       900
temp table 
cust_id  amount
12       300
13       190
14       110
15       240
20        30
25       210
28       500

我想使用客户id将记录从临时表更新到客户原始表。

可以使用merge语句完成。

merge into original_table ot
using temp_table tp
  on (ot.cust_id = tp.cust_id)
when matched 
then update set ot.amount = tp. amount

最新更新