update bb
set
m=(select a from aa where aa.a=bb.m)
where aa.a=bb.m
----------------
如果两个表的内容要求一样,那就把bb的数据清空,然后insert

解决方案 »

  1.   

    如果两个表的内容要求一样,那就把bb的数据清空,然后insert-------------------------------
    好方法,把bb数据清空set autocommit on
    delete from bb;insert into bb select * from aa where .......;set autocommit off
      

  2.   

    那样是不行的!我只并不过用了几个字段,其实aa 中有好多字段,而且记录是上千万条!而bb中只有几万条记录!
      

  3.   

    写程序吧,用一句update好像不行
      

  4.   


    update aa set (b,c)=(select n,s from bb where a=m)注意:a与m要唯一
      

  5.   

    我try过了,
    declare
    v_count number(10):=1;
    v_loop number(10):=1;
    v_a char(10);
    v_b char(10);
    v_c char(10);
    cursor c1 is select aa.a,aa.b,aa.c from aa,bb where bb.m=aa.a; 
    begin 
    select count(*) into v_count from bb,aa where bb.m=aa.a;
    open c1;
    loop
    fetch c1 into v_a,v_b,v_c;
    update bb set bb.n=v_b,bb.s=v_c where bb.a=v_a;
    commit;
    v_loop:=v_loop+1;
    exit when v_loop>v_count;
    end loop;
    close c1;
    end; 
    /
      

  6.   

    写程序,不行啊!还需要运行环境,还不灵活!
    难道直接用SQL语句就不能实现吗?
    我需要在WINDOWS、UNIX下都能执行,最好在SQL/PLUS里直接写一下了!
    各位帮帮忙!!想想办法啊!!谢谢!!
      

  7.   

    你这个没有文化的,这段程序直接可以在sqlplus中运行的。
    将上面程序ctrl-c
    进入sqlplus
    ctrl-v,即可
    别忘了最后的/
      

  8.   

    update aa set ( b,c )= ( select n,s from bb where aa.a=bb.m)
    where exists ( select 1 from bb where aa.a=bb.m)
      

  9.   

    Lastdrop(空杯) :
      你说的执行完全正确,真是太感谢你了!
      不过你能告诉我 select 1 from bb where aa.a=bb.m 这句话的含义吗?
      我知道 exists 是限制读取的范围,但是 selecct 1 是什么意思?有什么作用?
      麻烦你了!呵呵!我知道 coolmother() 写的能够执行,但是用游标太复杂了些,呵呵!!谢谢!
      

  10.   

    谢谢 Lastdrop(空杯)  ,结分!