oracle优雅for 循环插入 in loop insert

create table computers
(
 comNo number(4)  constraint PK_comp primary key,
 compModel varchar2(64) constraint unique_comp unique,
 buyTime date,
 price number(12,2) constraint ch_price check(
 price>0 and price<=300000),
 owner varchar2(32));

DECLARE
  i number := 0;
BEGIN
  for i in 1 .. 3000 loop
    insert into computers
      (comNo, compModel, buyTime, price, owner)
    values
      (i, '8' + i, to_date('' + sysdate, 'YYYY-MM'), i, 'zhangsan');
    --dbms_output.put_line(i);
  end loop;
  commit;
END;

posted @ 2015-06-14 10:19  172257861  阅读(265)  评论(0编辑  收藏  举报