在表格中生成测试数据

时间:2015-04-15 19:11:45

标签: sql oracle

如何快速生成此Oracle表的数据?

Table EVENTS

EVENTID NUMBER(38,0)
AGENTID NUMBER(38,0)
EVENTDATE   DATE
CPU NUMBER(38,0)
RAM NUMBER
HDD NUMBER
NETWORKUP   NUMBER
NETWORKDOWN NUMBER

例如,我可以使用Oracle函数执行1000个插入吗?

1 个答案:

答案 0 :(得分:0)

可以使用程序并在需要时调用它。

create or replace procedure addata is
begin
for i in 1..1000 loop

insert into events (EVENTID,
AGENTID ,
EVENTDATE, 
CPU, 
RAM ,
HDD ,
NETWORKUP, 
NETWORKDOWN) values 

(i,
i+1,
sysdate,
i+3,
i+4,
i+5,
i+6,
i+7) ;

end loop;
commit;
end;


SCOTT@research 16-APR-15> exec addata;

PL/SQL procedure successfully completed.

SCOTT@research 16-APR-15> select count(*) from events;

  COUNT(*)
----------
      1000