update trade a set name=(select name from cust where id=a.id) where exists
(select * from cust b where a.id=b.id)

解决方案 »

  1.   

    我是为了加快速度才要批量的,exists也影响速度啊,游标也慢
    如果是更新两个字段呢??
      

  2.   

    update 语句格式;update 表 set 字段1=(select ... from ...),字段2=(...),字段3...
      

  3.   

    楼上的方法我试过,要是update一个表的部分数据,还不用exists(效率问题)能实现吗
      

  4.   

    update tab1 set (col1,col2,col3...)=(select col1,col2,col3... from tab2 where tab1.key=tab2.key)
      

  5.   

    哦,这样应该更好些update tab1 set (col1,col2,col3...)=(select col1,col2,col3... from tab2 where key=tab1.key)
      

  6.   

    不行的,tab1表中的 不需要更新的记录的字段给赋予了空值,如果加上where exists
    (select * from tab2  where tab1.key = tab2.key )是可以的,但效率有问题
    希望高手能再给意见
      

  7.   

    where exists
    (select 1 from tab2  where tab1.key = tab2.key )
    把x改为1
      

  8.   

    初学 ORACLE 有很多地方不明白,请教个问题:
    TableA 表的字段: Num Number(5),Name VarChar(20)TableB 表的字段: Num Number(5),Name VarChar(20),IsOld Number(1) Default 0用 SQL 2000 的描述方法是:
    Update B 
        set B.Name = A.Name,B.IsOld = 0
       from TableA A,TableB B 
         where A.Num = B.Num and B.IsOld = 1;
    在 ORACLE 中怎实现?