MySQL存储过程,生成大量数据
2014年10月16日17:29:40
BEGIN
DECLARE ID INT;
DECLARE i INT;
DECLARE CARDID VARCHAR(16);
DECLARE IssuerID VARCHAR(16);
DECLARE ObuID VARCHAR(16);
DECLARE License VARCHAR(25);
DECLARE strID VARCHAR(2);
DECLARE strTmp1 VARCHAR(3);
DECLARE strTmp2 VARCHAR(3);
DECLARE strTmp3 VARCHAR(3);
DECLARE NetNo VARCHAR(4);
DECLARE LicenseName VARCHAR(4);
DECLARE LicenseNameA VARCHAR(4);
DECLARE LicenseNameB VARCHAR(4);
SET ID = 11;
SET LicenseName = '京';
SET strID = RIGHT(CONCAT('00',cast(ID as char(2))),2);
SET i=0;
set strTmp1 = '1';
SET strTmp1 = CONCAT(strID,'1');
SET strTmp2 = CONCAT(strID,'2');
SET strTmp3 = CONCAT(strID,'3');
SET NetNo = CONCAT(strID,'01');
SET LicenseNameA = CONCAT(LicenseName,'A');
SET LicenseNameB= CONCAT(LicenseName,'B');
WHILE i<100000 DO
SET CARDID = CONCAT(strTmp1,RIGHT(CONCAT('0000000000000',cast(i as char(16))),13));
SET IssuerID = CONCAT(strTmp2,RIGHT(CONCAT('0000000000000',cast(i as char(16))),13));
SET ObuID = CONCAT(strTmp3,RIGHT(CONCAT('0000000000000',cast(i as char(16))),13));
SET License = CONCAT(LicenseNameA,RIGHT(CONCAT('00000',cast(i as char(16))),5));
#SET CARDID = CONCAT('0847',cast(i as char(12)));
INSERT INTO `ETCBlackList11` VALUES (IssuerID, NetNo, CARDID, ObuID, License, '0', '0', '2000-01-01 00:00:00', '1', '2000-01-01 00:00:00', '测试', '16019', '0', '0', '0', null);
SET i = i + 1;
END WHILE;
WHILE i<200000 DO
SET CARDID = CONCAT(strTmp1,RIGHT(CONCAT('0000000000000',cast(i as char(16))),13));
SET IssuerID = CONCAT(strTmp2,RIGHT(CONCAT('0000000000000',cast(i as char(16))),13));
SET ObuID = CONCAT(strTmp3,RIGHT(CONCAT('0000000000000',cast(i as char(16))),13));
SET License = CONCAT(LicenseNameB,RIGHT(CONCAT('00000',cast(i as char(16))),5));
#SET CARDID = CONCAT('0847',cast(i as char(12)));
INSERT INTO `ETCBlackList11` VALUES (IssuerID, NetNo, CARDID, ObuID, License, '0', '0', '2000-01-01 00:00:00', '1', '2000-01-01 00:00:00', '测试', '16019', '0', '0', '0', null);
SET i = i + 1;
END WHILE;
END