码迷,mamicode.com
首页 > 数据库 > 详细

oracle优雅for 循环插入 in loop insert

时间:2015-06-14 11:01:01      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:oracle sql

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;

oracle优雅for 循环插入 in loop insert

标签:oracle sql

原文地址:http://blog.csdn.net/luozhonghua2014/article/details/46489569

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!