玩數據庫的,必定要會本身造測試數據。數據庫
這裏介紹四種,由簡單到複雜一丟丟bash
一 循環測試
DECLARE @i INT=1
WHILE @i<=9999
BEGIN
INSERT INTO ParTest VALUES(@i,'A')
SET @i=@i+1
END複製代碼
二 本身插本身ui
INSERT INTO Test(Content)
SELECT NEWID()
INSERT INTO Test(Content)
SELECT NEWID() FROM Test
GO 20複製代碼
三 系統表多用用spa
SELECT ROW_NUMBER() OVER(ORDER BY A.object_id)
FROM sys.objects A
CROSS JOIN sys.objects B
CROSS JOIN
(SELECT TOP 11 OBJECT_ID FROM sys.objects) C複製代碼
四 填充時間code
SELECT DateAdd(day,number,'2016-01-01')
FROM master..spt_values
WHERE type = 'p' AND number <= DateDiff(day,'2016-01-01','2016-12-31')複製代碼