表1
   id  money
    1    2.5
    ........ 
表2
   id1 money1
    1    3
     .......
用表2去修改表1的内容,我写的是:
update 表1 set money=(select a.money1 from 表2 a where a.id1=id) 
where  id in (select id1 from 表2)
一共30万条,执行很慢,请教更好的方法.马上给分,谢谢

解决方案 »

  1.   

    update 表1 set a.money=b.money1 from 表1 a,表2 b where a.id=b.id1
      

  2.   

    update 表1 b set money=(select a.money1 from 表2 a where a.id1=b.id)
      

  3.   

    update 表1 b set money=nvl((select a.money1 from 表2 a where a.id1=b.id),b.money)会不会快点呢?
      

  4.   

    create table 表3
    as 
    select a.id,b.money1 from 表1 a,表2 b
    where a.id=b.id1;update 表1 set money=(select a.money1 from 表3 a where a.id1=id)建个临时表,不知道会不会快点!
      

  5.   

    这个应该是可行的:
    update 表1 b set money=(select a.money1 from 表2 a where a.id1=b.id)
    如果还不行,应该在id1、id 上建立索引。
      

  6.   

    update 表1 a set a.money=(select b.money1 from 表2 b where a.id=b.id1)