大数据量下数据分页的方式

SQL Server 2000<?xml:namespace prefix = o />

PageCount:一页需要的数据条数

PageIndex:页索引

 

方式1

select top PageCount * from (

select top PageCount * from (

select top PageCount*PageIndex  *  from tableName order by ID) as tmp1 order by ID DESC

) as tmp2 order by ID

)

方式2

select * from tableName where ID in (

     select top PageCount BillID from (

        select top PageCount*PageIndex ID from tableName order by ID

     ) temp1 order by ID DESC

) order by ID

 

Oracle 9i

SQL:普通的Select语句

FromIndex:从…条

ToIndex:到…条

通用的方式:

select * from (

     select row_.*, rownum rownum_ from (
       SQL

) row_ where rownum <= toIndex
) where rownum_ > fromIndex

 

有唯一标识符(ID字段)的情况排序

select * from tableName where ID in(
  select
ID from (
    select rownum rownum_,
ID from (
      select ID from
tableName order by Code
    ) where rownum <=
toIndex
  ) where rownum_ >
fromIndex
)

转载于:https://www.cnblogs.com/Sniper/archive/2004/08/10/31765.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值