About me:Oracle ACE pro,optimistic,passionate and harmonious.
Focus on ORACLE,MySQL and other database programming,peformance tuning,db design, j2ee,Linux/AIX,Architecture tech,etc
oracle更新语法: 1.一般语法 update tab set col = .... [where ...] =后可以有子查询,但是必须对于tab的每一列返回唯一一行与之对应,where是需要更新的表,部分更新必须加,否则相关子查询的更新会把没有匹配的更新为null,如: update tab a set a.col=(select b.col from b where a.id=b.id) where exists (select 1 from b where a.id=b.id)
2.改进语法merge merge into tab using (表|视图|子查询等) --子查询需要加括号 when match then do update when no match then do insert
如果是基于一个表的,那么可以更新插入,删除,当然也得满足对视图DML的要求,比如rownum等,没有preserved key要求 UPDATE (SELECT * FROM t1) SET NAME='x' WHERE ID=1; UPDATE (SELECT NAME FROM t1) SET NAME='x' WHERE NAME='m'; DELETE FROM (SELECT * FROM t1) WHERE ID=1