-- Create the table.
CREATE TABLE TestTable (cola INT, colb CHAR(3))
GO
SET NOCOUNT ON
GO
-- Declare the variable to be used.
DECLARE @MyCounter INT-- Initialize the variable.
SET @MyCounter = 0-- Test the variable to see if the loop is finished.
WHILE (@MyCounter < 100000)
BEGIN
   -- Insert a row into the table.
   INSERT INTO TestTable VALUES
       (@MyCounter,'aaa')
   -- Increment the variable to count this iteration
   -- of the loop.
   SET @MyCounter = @MyCounter + 1
END
GO
SET NOCOUNT OFF
GO

解决方案 »

  1.   

    to wwl007(疑难杂症) 对对,就是这样
    教我怎么写SQL:)
      

  2.   

    on oracle8i sql*plus:insert into tab select * from tab;/
      

  3.   

    oracle 8:
    declare
    i integer;
    k varchar2(10);
    begin
      for i in 1..100000 loop
        k:=to_char(i);
        insert into testtable (i,k);
      end loop;
      commit;
    end;
      

  4.   

    一定要用循环呢,不能用一句SQL来完成么
    我试了insert...select语句,好像试不出来:(
      

  5.   

    insert a select * from b
    前提是你的表b已经有现成的数据才行,而且表a和表b的结构完全一样。如果没有主键,重复执行也可以。
      

  6.   

    第一个1000必须用循环!
    下面的就可以不用了
    例如你用循环生成了100条数据!
    哪吗下面可以这样处理
    !
    insert  into tablename()
    select primary key +1,... from tablename 
    insert into tablename()
    select primary key +1,... from tablename 
    ..
    就是这样了!
      

  7.   

    如果你的表中有记录的话
    那么
    insert into tablename
    select a.* 
    from tablename a cross join tablename b这样重复做几次,我想就会到你要求的数量。