weiruan85 发表于 2013-1-13 18:57:55

oracle merge的用法

下边是脚本:
drop table inventory;drop table shipment;create table inventory (part_no int,part_count int);insert into inventory values(1,5);create table shipment (part_no int,part_count int);insert into shipment values(1,2);select * from inventory;select * from shipment;MERGE INTO inventory    USING shipment    ON (inventory.part_no = shipment.part_no)WHEN MATCHED THEN   UPDATE SET inventory.part_count = inventory.part_count + shipment.part_countWHEN NOT MATCHED THEN   INSERT VALUES (shipment.part_no,shipment.part_count);

注意在update set后边的列如果不加表名称限制,则默认是:using 后边的表

<div class="quote_title">引用
页: [1]
查看完整版本: oracle merge的用法