oracle批量生成随机数据

 EMPNO											 NUMBER(4)
 ENAME											 VARCHAR2(10)
 JOB											 VARCHAR2(9)
 MGR											 NUMBER(4)
 HIREDATE										 DATE
 SAL											 NUMBER(7,2)
 COMM											 NUMBER(7,2)
 DEPTNO 										 NUMBER(2)


begin
  for i in 1..10000 loop
    insert into emp1 (empno,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO) values(FLOOR(DBMS_RANDOM.VALUE(0, 10000)),DBMS_RANDOM.STRING('U', 10),DBMS_RANDOM.STRING('j', 6),FLOOR(DBMS_RANDOM.VALUE(0, 10000)),sysdate+dbms_random.value+ABS(MOD(DBMS_RANDOM.RANDOM,30)),FLOOR(DBMS_RANDOM.VALUE(0, 100000)),FLOOR(DBMS_RANDOM.VALUE(0, 10000)),FLOOR(DBMS_RANDOM.VALUE(0, 100)));
	commit;
  end loop;
end;
/

单行插入

begin
  for i in 1..10000 loop
    insert into emp1 (empno) values(FLOOR(DBMS_RANDOM.VALUE(0, 10000)));
    insert into emp1 (ENAME) values(DBMS_RANDOM.STRING('U', 10));
	insert into emp1 (JOB) values(DBMS_RANDOM.STRING('j', 6)); 
	insert into emp1 (MGR) values(FLOOR(DBMS_RANDOM.VALUE(0, 10000)));
	insert into emp1 (HIREDATE) values(sysdate+dbms_random.value+ABS(MOD(DBMS_RANDOM.RANDOM,30)));
	insert into emp1 (SAL) values(FLOOR(DBMS_RANDOM.VALUE(0, 100000)));
	insert into emp1 (COMM) values(FLOOR(DBMS_RANDOM.VALUE(0, 10000)));
	insert into emp1 (SAL) values(FLOOR(DBMS_RANDOM.VALUE(0, 100000)));
  end loop;
end;
/

你可能感兴趣的:(oracle,数据库)