我们知道,在SQL Server数据库操作中,有时候需要我们生成大量的数据,比如说在做性能测试的时候,经常会遇到需要大量的数据用来做交易,例如银行的缴费,当一条数据缴完后就不能再缴费了,所以需要造大量的数据用来做性能测试,本文我们通过做某银行校园卡缴费性能测试,根据表的特点,编写的一个存储过程,代码如下:
declare busiId varchar2(20); corpId varchar2(20); termId varchar2(10); collegeId varchar(30); collegeName varchar(40); stuId varchar2(30); begin busiId := '100104'; --业务代码 corpId := 'E000000059'; --委托单位 termId := '0101'; --学期 collegeId := '010590'; --学校代码 collegeName := '深圳大学'; stuId := '59'; --增加学校信息 insert into bib_booking_coll_info(busi_id,corp_id,term_id,term_flag,college_id,college_name,start_date,end_date) values(busiId,corpId,termId,'1',collegeId,collegeName,'20110520','20110527'); --增加学校费项信息 for fee_num in 1..4 loop insert into bib_coll_fee_info(busi_id,corp_id,cost_code,cost_name) values(busiId,corpId,'100'|| fee_num,'费项'||fee_num); end loop; --增加学生缴费信息 for student_num in 1..100000 loop insert into bib_booking_student_info (busi_id, corp_id, term_id, stu_id, college_id, bank_acnt, stu_dep, stu_speciality, stu_name, need_totalamt, stu_stat) values (busiId, corpId, termId, stuId||lpad(student_num,'6','0'), collegeId, '6029071032159548', '计算机科学', '计算机', '测试'||student_num, '4', '0'); --增加学生费项缴费信息 for stu_fee in 1..4 loop insert into bib_booking_fee_info (busi_id, corp_id, term_id, stu_id, cost_code, college_id, cost_amt, stu_stat) values (busiId, corpId, termId, stuId||lpad(student_num,'6','0'), '100'|| stu_fee, collegeId, '1', '0'); end loop; end loop; commit; end;
看过以上的代码,相信大家一定能了解SQL Server数据库用存储过程生成大量数据的方法了,本文就介绍到这里,希望能够给您带来一些收获。