例如A表 存在一下字段:
AID   A1    A2     A3   A4B表中存在字段:
BID   B1    B2     B3   B4如果实现用B表的所有字段更新A表中相应的字段,在MS SQL Server里面可以写成:
update A
set A1=B.B1,A2=B.B2,A3=B.B3,A4=B.B4
from A,B
where A.AID=B.BID但是在oracle 9i里面怎么样,好像向SQL Server不一样?
请各位大侠帮助!

解决方案 »

  1.   

    create table a (aid type,a1 type,a2 type,a3 type) 
    as select * from b好像省事点
      

  2.   

    update A
    set (A1,a2,a3,a4) = (
    select b.b1,b.b2,b.b3,b.b4
    from B
    where A.AID=B.BID)
      

  3.   

    update a
    set (a1,a2,a3,a4) = (
    select b.b1,b.b2,b.b3,b.b4
    from b
    where a.aid=b.aid)
    where exists (select 1 from b where a.aid=b.bid)加上EXISTS会好些   保证ID之间关联只能返回一条记录  否则报错
      

  4.   

    update   a 
    set   (a.a1,a.a2,a.a3,a.a4)   =   ( 
    select   b.b1,b.b2,b.b3,b.b4 
    from   b 
    where   a.aid=b.aid) 
    where   exists   (select   1   from   b   where   a.aid=b.bid) 
    这个是没有问题的。。