All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
Sql,server,2005带来的分页便利_[SQL,Server教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/1 0:10:11 Browse times: 335 Comment times: 0

Sql,server,2005带来的分页便利_[SQL,Server教程]


Head photo

Go homepage
Upload pictures
Write articles

Sql server 2005带来的分页便利_[SQL Server教程]

select threadid from
(
select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads
) as T
where T.Pos > 100000 and T.Pos < 100030

===========================================

如果里面的这个表cs_threads数据量超大,比如,几亿条记录,那这个方法应该是有问题的

因为,select threadid from
(
select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads
) as T
where T.Pos > 100000 and T.Pos < 100030
这个语句是把select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads它全部取出来,然后在SQL的外面进行分页的,没在SQL2005上测试过,因为原先在ORACLE上这样的写法是不好的,ORACLE中这样写比较好:select threadid from
(
select threadid, ROW_NUMBER() OVER (order by stickydate) as Pos from cs_threads a where a.pos<100030
) as T
where T.Pos > 100000

出处:blog.joycode.com/dotey/archive/2006/01/16/70493.aspx





There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.