oracle更新语句merge和update

update:

     update语句更新需要根据索引或者数据列遍历所有行

     语句举例:

     update table1  a set column1=(select column from table2 b where a.col=b.col)

merge:merge只需要遍历一次表,,可以更新可以插入

    语句举例:

    merge into table1 a

    using (select col1,co2 from table2 where col3 条件) table2 on a.colm=table2.colm --链接条件

    when matched then

    update  set a.colu=table2.column

    delete where (table2.col>5000) --只删除满足条件的语句

    when not matched then

    insert into a (a.colu1,a.colu2) valus(table2.col1,table2.co2) where (table2.colu<5000) --插入满足条件的语句

  

posted @ 2016-07-14 10:36  Wind_LPH  阅读(1534)  评论(0编辑  收藏  举报