恐怕只能用WHILE. 这么点纪录效率不是问题.
在ORACLE中我通常会这么写:
BEGIN
  FOR I IN 1..10 LOOP
    INSERT INTO TABLE1
    VALUES (1,I,2);
  END LOOP;
END;

解决方案 »

  1.   

    恐怕只能用循环. 这么点纪录效率不是问题.
    在ORACLE中我通常会这么写:
    BEGIN
      FOR I IN 1..10 LOOP
        INSERT INTO TABLE1
        VALUES (1,I,2);
      END LOOP;
    END;
      

  2.   

    用循环没什么不好,下面这样也可以,但不知道是不是效率更高?
    select top 10 1 as id,identity(int,1,1) as cola,2 as colb
    into #temptablename
    from sysobjectsinsert into tablename select * from #temptablename我这里用的sysobjects 表,用任何记录数>=10的表也可以。
      

  3.   

    Oracle:
    insert into Y
    select 1,rownum,2 from user_tables where rownum <= 10;
      

  4.   

    或者Oracle8.15以上版本:insert into Y
    select 1,rank() over(order by table_name asc nulls last) rank,2 from user_tables where rownum <= 10;
      

  5.   

    小草:
    你的后面两种写法必须保证USER_TABLES有10条或者以上的纪录, 如果USER只有少于10个的表,就会少加入纪录.其实用循环没什么不好的, 而且从逻辑上来说更合理.