go
-- 建索引
create clustered index ix_userinfo_classid on t_userinfo(classid)
go
-- step 2.
declare @i int
declare @k int
declare @nick varchar(10)
set @i = 1
while @i<1000000
begin
set @k = @i % 10
set @nick = convert(varchar,@i)
insert into t_userinfo(nick,classid,writetime) values(@nick,@k,getdate())
set @i = @i + 1
end
-- 耗时 08:27 ,需要耐心等待
-- step 3.
select top 20 userid,nick,classid,writetime from t_userinfo
where userid not in
(
select top 900000 userid from t_userinfo order by userid asc
)
-- 耗时 8 秒 ,够长的
文章来源于领测软件测试网 https://www.ltesting.net/