a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 166|回复: 0

[考试辅导] oracle认证辅导:批量插入测试数据

[复制链接]
发表于 2012-8-4 14:06:19 | 显示全部楼层 |阅读模式
一、Test Windos方式   declare5 e) ~: ^( n0 ?; p+ k
  maxrecords constant int:=100000;: U6 t3 }+ Z  E' N' f& @1 ?
  i int :=1;+ o7 r0 W" E: B+ m, M# i- @- g5 a
  begin
3 o# Y2 F, s7 I8 j2 p$ c0 c  for i in 1..maxrecords loop
; {( X* z% e' k. u' b  insert into test2# C" _; B. l( f8 G% c" E* f
  (id, name)
3 }5 a' ?* m) {/ w% U5 \$ e  values
% ]5 W* w- p- t9 W: C  (test2_seq.nextval, to_char(9999+i));
3 U( O+ K2 K1 q: Q" L, @: d, b+ R  end loop;8 C; c% O/ v4 F
  dbms_output.put_line(' 成功录入数据!');) i" p$ Y; {( B
  commit;4 z1 A0 o% G' M; T/ E
  end;- B' j# Z6 Z) c7 c  x) T% `1 `# d
  二、从已有表中往入另一张表导数据& v" Z! N5 u" a
  create or replace procedure TestProc is
  Y& h: s' A) L7 t5 w$ ]  begin
& {# k: C+ f, X, y2 h  for c in(select id, name from test2) loop3 q/ s7 h- b9 I  G
  insert into test% [2 V( j& ]1 {
  (id,
: N: j- Q2 _0 i, m- G  j  name)& D! [/ W  j) }: ]* P0 x9 F, k
  values% F5 |* y: v* f) m) W3 H
  (test_seq.nextval, c.name);. m7 @) b$ y; l4 Q9 ^
  end loop;: g+ S$ t/ n# r+ o5 f/ l) U( ]* t6 A
  end TestProc;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-5 20:58 , Processed in 0.413004 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表