declare @d datetime
set @d=getdate()
select * from dbo.ChunkSegmentMapping
select [语句执行花费时间(毫秒)]=datediff(ms,@d,getdate())
USE tempdb
GO
CREATE TABLE tb(id char(8))
CREATE UNIQUE INDEX IX_tb ON tb(id)
WITH IGNORE_DUP_KEY -- --忽略重复记录的索引
GO
DECLARE @dt datetime
SET @dt = GETDATE()
SET NOCOUNT OFF
DECLARE @row int
SET @row = 1000000 --记录总数为100W
WHILE @row >0
BEGIN
RAISERROR('need %d rows', 10, 1, @row) WITH NOWAIT
SET ROWCOUNT @row
INSERT tb SELECT
id = RIGHT(100000000 + CONVERT(bigint, ABS(CHECKSUM(NEWID()))), 8)
--FROM syscolumns c1, syscolumns c2 -- SET NOCOUNT ON 49 Second
FROM syscolumns c1, sysobjects o -- SET NOCOUNT ON 47 Second
SET @row = @row - @@ROWCOUNT --设置下次循环需要插入的记录数量
END
SELECT BeginDate = @dt, EndDate = GETDATE(), Second = DATEDIFF(Second, @dt, GETDATE())
GO
SELECT COUNT(*) FROM tb
GO
SELECT * FROM tb
DROP TABLE tb
快速生成100W数据
最新推荐文章于 2023-09-29 21:40:56 发布