一、SQL server 2012循环写入压力测试
1.写入数据
/* 1. 测试数据库中写入情况 */
declare @i int
set @i=1
while @i<1000000
begin
INSERT INTO QDDBD_TEST1(DJBH,RQ,Djxz,FPLX,LXDJ,DM1,DM1_1,QDDM,QYDM,SL,JE,BZJE,CJ,YS,YSRQ,sh,SHRQ,SP,ZDR,YXRQ)
VALUES('DA3020101046283',GETDATE(),1,0,'DA1141224022933','BA0030','000','A01001','A00001','100','300','669.0000',
'0.0000','0',GETDATE(),'1',GETDATE(),'0','周源',GETDATE())
set @i=@i+1
end
2.查询生成的结果
SELECT * FROM QDDBD_TEST1
二、MySQL循环写入压力测试
注:MySQL中不能直接运行循环语句会报错()
1.创建一张与数库中结构一样的表
CREATE TABLE lsxhd_test as SELECT * from lsxhd LIMIT 1
- TRUNCATE lsxhd_test
2.写存储过程
-- 1. 循环生成记录
CREATE PROCEDURE p_lsxhdtest100W()
BEGIN
DECLARE i INT;
SET i = 0;
REPEAT
INSERT INTO lsxhd_test (`Id`, `pid`, `tn_id`, `djbh`, `ydjh`, `rq`, `org_id`, `zd_id`, `sl`, `sl_1`, `sl_2`, `sl_3`, `je`, `je_1`, `je_2`, `je_3`, `qr`, `qrrq`, `tj`, `tjrq`, `zdfx`, `zdr`, `zdrq`, `bz`, `row_no`, `alterdate`, `lastchanged`, `gid`, `kw_id`, `zddm`, `zdmc`)
VALUES ('129855', NULL, NULL, 'LS0007_lsd000060', NULL, UNIX_TIMESTAMP(now()), '14164', '14209', '1', '0', '0', '0', '461.00', '0.00', '0.00', '0.00', '1', UNIX_TIMESTAMP(now()), '1', NULL, '1', '默认店长', '1408932366', '2014-08-24 由小票日结产生; 本次日结小票尾号有:qtsy000313,', NULL, NULL, now(), '5faf8cb0-2bfc-11e4-b860-6cae8b781cd0', '1', 'LS0007', 'Q甘肃定西岷县步行街店');
SET i = i + 1;
UNTIL i >= 1000000
END REPEAT;
END;
-- 2.调用存储过程
CALL p_lsxhdtest100W();