Oracle数据库创建随机测试数据

(1)创建表test01

create table test01
(
col1 number, 
col2 number,
col3 date,
col4 varchar2(30),
col5 varchar2(100) 
);

 

(2)创建自增序列

CREATE SEQUENCE seq01
START WITH 1
MAXVALUE 99999999
MINVALUE 0
CYCLE
CACHE 10
ORDER;

 

(3)创建随机数据插入存储过程,其中col1列单调递增

create or replace procedure p_insert_test01 IS
v_col1 NUMBER;
BEGIN
FOR i IN 1..10000 LOOP
select seq01.nextval INTO v_col1 from dual;
insert into test01(col1,col2,col3,col4,col5)
values
(v_col1,
(select round(dbms_random.value(10000, 100000000)) from dual),
sysdate,
(select dbms_random.string('a', 25) from dual),
(select dbms_random.string('a', 85) from dual));
END LOOP;
commit;
end p_insert_test01;

 

(4)制定job,没隔30s执行一次上面的存储过程

declare
job1 number;
begin
sys.dbms_job.submit(job => job1,
what => 'p_insert_test01;',
next_date => sysdate,
interval => 'sysdate + 30/(1440*60)'); --每隔30s向test01表插入10000笔随机数据
commit;
end;
/

 

 

相关文档集合:

1.MySQL数据库创建随机测试数据
2.Oracle数据库创建随机测试数据

posted @ 2020-04-21 20:54  gegeman  阅读(1205)  评论(0编辑  收藏  举报