zoukankan      html  css  js  c++  java
  • delete/update/insert by join

    //delete
    delete from table1 a 
          where exists (select 1 
                          from table2 b 
                         where a.col1 = b.col1)
                         
    //insert 
    insert into table1 (
           col1,
           col2
    )select
           'a',
           'b'
      from dual
     where not exists (select 1
                         from table2
                        where index = ?)

     

     

    //update

      update /*+ bypass_ujvc */
             (select col1
                      from table1 a,
                             table2 b
                     where a.seq = b.seq
                       and a.code = '100000002972' )
               set col1 = '100'

    PS:/*+ bypass_ujvc */ 这个Hint 的意思是,两个表的关系是1:1

  • 相关阅读:
    C# WPF – 利用“Attached Property” 把 RoutedEvent 接上 ICommand
    文件输入输出代码
    strcpy()
    heaplog
    单链表范例
    贪吃蛇
    时钟程序
    herizai_CD2所做答案
    6月25日代码
    6月24日代码
  • 原文地址:https://www.cnblogs.com/kevinkim/p/2343946.html
Copyright © 2011-2022 走看看