欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

MySQL與MSSQl使用While語句循環(huán)生成測(cè)試數(shù)據(jù)的代碼

 更新時(shí)間:2010年12月17日 14:21:10   作者:  
有時(shí)候我們測(cè)試性能的時(shí)候經(jīng)常需要生產(chǎn)大量的測(cè)試數(shù)據(jù),用sql語句直接生成的數(shù)據(jù)更快,需要的朋友可以參考下。
在MySQL中,使用While語句循環(huán)與SQL Server中有所不同,代碼測(cè)試通過。

MSSQL中使用while語句循環(huán)生成數(shù)據(jù)的方法:

示例代碼:
復(fù)制代碼 代碼如下:

declare @a int
set @a = 1
while @a<25
begin
INSERT INTO demotable (id,item1,item2) VALUES (@a,"abc","123")
set @a = @a + 1
end

MySQL中,使用while循環(huán)處理數(shù)據(jù)方法:需要新建為存儲(chǔ)過程,直接調(diào)用執(zhí)行存儲(chǔ)過程。

示例代碼:
復(fù)制代碼 代碼如下:

CREATE DEFINER=`root`@`localhost` PROCEDURE `NewProcedure`()
BEGIN
DECLARE i INT;
SET i=1;
WHILE i<100 DO
INSERT INTO demotable (id,item1,item2) VALUES (i,"測(cè)試試題","0");
SET i = i + 1;
END WHILE;
END;

相關(guān)文章

最新評(píng)論