Personally, I think it's a good writing.
http://blog.csdn.net/wanglilin/article/details/7200201
Demand:
Update the records in the T2 (T_STATBUF) table with the same ID as the T1 (T_MT) table into the T1 table.
1. The wrong wording:
1 update table_name T1 set (a,b,c)=( select a,b,c from Table_ name_2 T2 where t1.a=t2.a);
In this notation, all rows in the T1 table are updated: If t1.a=t2.a, the records detected in T2 are updated to T1, and if t1.a<>t2.a, the records in T1 are updated to empty (null).
The correct wording:
1 Update Set (A,B,C) = Select from where t1.a=t2.a)2whereexists(select1 fromwhere t1.a=t2.a);
Analytical:
The correct way to do this is to add a exists in the back (select 1 from table_name_2 T2 where t1.a=t2.a);
This sentence means: if there is t1.a=t2.a, update, otherwise, do not update, so will not cause all the records in the T1 table are updated.
Cases:
Update Table_name_1 Set (A, b) = (select from dual where 1=2);
This result will update all the records in the table_name_1 to null (NULL), since the 1=2 behind is not valid.
Summarize:
Update, to understand the qualification, to test!
My test statement:
1 Update Set = (Select from 2 where t1. Discript=whereexists (select1from 3 where t1. Discript=T2. Discript);
My business statement:
1 UpdateT_MT T1Set(Stat,ostat,rpttime)=( 2 SelectStat,stat,rpttime fromT_statbuf T2whereT1. MsgId=T2. MSGID)where exists( 3 Select 1 fromT_statbuf T2whereT1. MsgId=T2. MSGID);--if there are T1 and T2 equal, it is updated. Does not add where exists, whether the deposit does not exist, is updated, does not exist, the results will be updated to empty, but the record is still
Oracle Batch update turn