往一个表里写数据,写100条,数据是每条+1
用存储过程怎么写
insert into test(id, name) values(1, 'test1');
insert into test(id, name) values(2, 'test2');
insert into test(id, name) values(3, 'test3');
insert into test(id, name) values(4, 'test4');
。。
insert into test(id, name) values(100, 'test100');

解决方案 »

  1.   

    create table test(id number, name varchar2(20));create or replace procedure insert_sth(p_cnt in number) is
        i int := 0;
    begin
        for i in 1 .. p_cnt loop
            insert into test (id, name) values (i, 'test' || i);
        end loop;
    end;
    begin 
        insert_sth(100);
        commit;
    end;select * from test;1 test1
    2 test2
    3 test3
    4 test4
    5 test5
    6 test6
    ...
      

  2.   

    数据是每条+1是不是test的值是递增的?那么有没有初始值? 如果有的话那就简单多了
      

  3.   

    insert into test(id, name)
    select rownum ,'test'||rownum
    from dual
    connect by rownum <101