Random value based on sequence
SQL> create table emp (id number(6) );
Table created.
SQL>
SQL> alter table emp modify id number(12);
Table altered.
SQL>
SQL> create sequence cust_seq cache 1000
2 start with 100000;
Sequence created.
SQL>
SQL> create or replace procedure gen_emp is
2 v_new_cid emp.id%type;
3 begin
4 insert into emp values (cust_seq.nextval*100000+ round(dbms_random.value(100000,999999)));
5 end;
6 /
Procedure created.
SQL>
SQL> begin
2 for i in 1 .. 10000 loop
3 gen_emp;
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> drop sequence cust_seq;
Sequence dropped.
SQL>
SQL>
SQL> drop table emp;
Table dropped.
Related examples in the same category