SQLServer循环插入100万条记录
CREATE TABLE [dbo].[task] (
[taskid] int IDENTITY(1,1) NOT NULL,
[taskname] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
[createdtime] datetime NULL,
CONSTRAINT [PK__task__DD5E468A1F5BD1F5] PRIMARY KEY CLUSTERED ([taskid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[task] SET (LOCK_ESCALATION = TABLE)
开始循环插入:
declare @num int
set @num =0
while(@num<1000000)
begin
set @num = @num+1
insert dbo.task (taskname,createdtime) values('测试', GETDATE())
END
该方法用于快速插入测试数据,进行性能测试·
Tag标签:「记录 循环」更新时间:「2021-11-15 11:13:20」阅读次数:「961」