`
eyejava
  • 浏览: 1256381 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

oracle merge into 10G增强

    博客分类:
  • DB
阅读更多
http://www.oracle-base.com/articles/10g/MergeEnhancements10g.php
如果在9i中执行以下sql将报错:ora-00905:missing keyword
Merge Into card a
Using etl_cardinfo b On (a.card_number = b.card_no)
WHEN MATCHED Then
Update Set a.open_date=b.issue_date,a.card_limit=b.card_limit
;

在10G 中:The MATCHED and NOT MATCHED clauses are now optional making all of the following examples valid.
-- Both clauses present.
MERGE INTO test1 a
  USING all_objects b
    ON (a.object_id = b.object_id)
  WHEN MATCHED THEN
    UPDATE SET a.status = b.status
  WHEN NOT MATCHED THEN
    INSERT (object_id, status)
    VALUES (b.object_id, b.status);

-- No matched clause, insert only.
MERGE INTO test1 a
  USING all_objects b
    ON (a.object_id = b.object_id)
  WHEN NOT MATCHED THEN
    INSERT (object_id, status)
    VALUES (b.object_id, b.status);

-- No not-matched clause, update only.
MERGE INTO test1 a
  USING all_objects b
    ON (a.object_id = b.object_id)
  WHEN MATCHED THEN
    UPDATE SET a.status = b.status;
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics