insert into b select (select max(b_id) from b)+rownum,max(b_id) over(order by b_id),b_name,1 from b where a_id=1;

解决方案 »

  1.   

    这里有介绍分析函数:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm#81409
      

  2.   

    [最新需求如下]
    表C结构如下:
    name order topic id
     aa    1    aaa   1
     bb    2    bbb   1
     cc    4    ccc   1复制表C的id为1的数据一份,其中name和topic与原数据相同,order能够从1开始以1递增重新排序,id为新的6,即新的数据如下:
    name order topic id
     aa    1    aaa   6
     bb    2    bbb   6
     cc    3    ccc   6请问如何写insert语句?
      

  3.   

    insert into b 
    select (select max(b_id) from b)+rownum,rownum,topic,6 from c where id=1
      

  4.   

    你需要的SQL语句中主要的问题是生成一个序列号,是否可以针对表B.b_id和表C.id创建一个SEQUENCE