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

原文地址:https://www.cnblogs.com/kevinkim/p/2343946.html