sql 数据库循环插入100条记录! 怎么实现? 是不是得用存储过程啊

如题所述

1、创建测试表,

create table test_loop(id varchar2(20),remark varchar2(20));

2、循环插入测试数据;

begin

  for i in 1..100 loop

     insert into test_loop

values(i,'level_'||i);

  end loop;

commit;

end;

3、查询表中全量数据;select t.*, rowid from test_loop t;

4、编写语句,查询表中记录数,可以看到结果为100;

   select count(*) sec from test_loop t ;

温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-07-18
不用,举个例子,将1-100循环插入tablename表中的字段
declare @i int
set @i=1
while @i<=100
begin
insert into tablename (字段) values @i
set @i=@i+1
end
第2个回答  推荐于2018-03-02
declare @a as int
set @a=1
while(@a<=100)
begin
insert into table1 values('','','','')
set @a=@a+1
if @a>100
break
else
continue
end追问

很详细很给力

本回答被提问者和网友采纳