三种分页
发布时间:2020-12-12 15:18:39 所属栏目:MsSql教程 来源:网络整理
导读:比较了3种分页方式,分别是max方案,top方案,row方案 效率: ? 第1:row ? 第2:max ? 第3:top 缺点: ? max:必须用户编写复杂Sql,不支持非唯一列排序 ? top:必须用户编写复杂Sql,不支持复合主键 ? row:不支持sqlServer2000 测试数据: 共 320万 条数
比较了3种分页方式,分别是max方案,top方案,row方案 select top 10 * from Table1 where Id not in ( select top 开始的位置 Id from Table1)
select top 10 * from Table1 where Id > ( select max (Id) from ( select top 开始位置 Id from Table1order by Id)tt)
select * from ( select row_number() over ( order by tempColumn)tempRowNumber, * from ( select top 开始位置 + 10 tempColumn = 0 , * from Table1)t )tt where tempRowNumber > 开始位置 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |