是不是这样:
alter table b add(age,number);
update b set b.age=(select age from a)+1 where a.id=b.id;

解决方案 »

  1.   

    这么小的过程,写一下不就行了。
    不是什么事情都要一体sql解决的。
      

  2.   

    insert into b select col1+1,col2,... from a;
      

  3.   

    BlueskyWide(谈趣者) :
    你写的是不是不对呀,你那是更新的,楼主要求的是插入的。
    bzszp(SongZip) :
    你的就更不对了,误人子弟。
    楼主的意思是不是插入到表B时,除了年龄数加工1,其余的都不变呢?
    呵呵,不过我也不会做,观注中。
      

  4.   

    insert into b 
    select * from 
    (select age+1 from a
    union 
    select age+2 from a
    union
    .....  age+x from a
    )
      

  5.   

    create or replace procedure name_pro(p in number)
    as
    --cursor t_sor is
    select age from a;
    begin 
    for i in 1..p loop
    insert into b select age+i from a;
    end loop;
    end;
    /begin
    name_pro(6);
    end;
    /
      

  6.   

    这样行吗:
    ------------------------------
    insert into b select age+nn from a,(select rownum nn from 表c) where nn<=account;其中:表c表示另外一个有足够记录的表,既然是年龄,我想大概有100条记录的也就差不多了,如果表a记录够多,也可以用表a,也就是:
    ------------------------------
    insert into b select age+nn from a,(select rownum nn from 表c) where nn<=account;如果实在没有,随便建一个或找个系统表就好了!
      

  7.   

    下面的SQL的效果是将表A中的记录,按照表A的account的值,"循环"插入,也就是一条记录插入account次,age按照你的题意是加1,也可以a.age+c.no,那就是"循环"增加了。insert into b
    ( select a.col1,a.col2,a.age+1,..
      from a,( select rownum no from all_objects ) c
      where c.no < a.account+1
    )
      

  8.   

    Lastdrop(空杯) 的想法是对的,问题在于all_objects 的行数小于a.account时,结果就不对了,这种情况很难用一句话实现的,当然,可以用比较笨的办法构造一个比较大的基数
    改造: Lastdrop(空杯) 的语句
    insert into b
    ( select a.col1,a.col2,a.age+1,..
      from a,( select rownum no from 
       (select rownum no from all_objects
        union all
         select rownum no from all_objects
        union all
         select rownum no from all_objects--注多少个union all 根据你自己的具体情况定
       )
     ) c
      where c.no < a.account+1
    )
      

  9.   

    谢谢各位了!
    我的意思是age循环加1,即第一条为1,第二条为2,第三条为3…….直到最后一条记录的age值等于account的值!
      

  10.   

    insert into b
    ( select a.col1,a.col2,a.age+c.no,..
      from a,( select rownum no from all_objects ) c
      where c.no < ( a.account - a.age ) + 1
    )
      

  11.   


    我还没有验证你的SQL语句,因为没有数据。