在ORCALE里造数据需要良好PL/SQL功底。而PL/SQL的精髓是循环语句,说的不好不要笑。
给个例子代码,相信更清晰。
declare
index_ number:= 1;
cusno varchar2(12);
linid varchar2(20);
begin----开始
delete from tbl_contactinfos;
delete from tbl_cust_linkman;
delete from tbl_customer_info;
commit;
loop
exit when index_ > 30000;
select trunc(dbms_random.value(10,99))||trunc(dbms_random.value(10000000,99999999)) into cusno from dual;
select trunc(dbms_random.value(10,99))||trunc(dbms_random.value(10000000,99999999)) into linid from dual;
insert into v_tbl_customer_info values(---一号表
cusno,trunc(dbms_random.value(1,5)) ,
trunc(dbms_random.value(0,1)),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
trunc(dbms_random.value(10000000,99999999)),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
trunc(dbms_random.value(0,1)),0,0);
insert into v_tbl_cust_linkman values(--2号表
cusno,linid,
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
trunc(dbms_random.value(100000,999999)),
trunc(dbms_random.value(10000000,99999999)),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||'@express.com',0,0
);
insert into v_tbl_contactinfos values(---三号表
linid,trunc(dbms_random.value(10000000,99999999)),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90)))||
chr(trunc(dbms_random.value(65,90)))||chr(trunc(dbms_random.value(65,90))),
'13'||trunc(dbms_random.value(0,9))||trunc(dbms_random.value(10000000,99999999)),
trunc(dbms_random.value(0,3)),
trunc(dbms_random.value(100,999)),
trunc(dbms_random.value(100,999)),
trunc(dbms_random.value(100,999)),0,0 );
index_ := index_ +1;--循环控制,我建议用FOR控制
if Mod(index_,1000) = 0 then commit;---每一千递交一次
end if;
end loop;
commit;-----最后递交
end;----语句块结束
看了这块代码:我相信生成 邮件、电话号码、中文取字、系列号、GUID、时间、串等都是可以搞定的,就看你怎么利用了。