`
天空之城
  • 浏览: 397098 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Oracle、SQL和DB2分页查询写法介绍

 
阅读更多

DB2分页查询和Oracle、SQL中的分页查询语句写法都不太一样,下面就为您介绍DB2分页查询和其他数据库中分页查询的区别,希望对您有所帮助。

Oracle分页查询写法:

一:Oracle 
 

  select * from (select rownum,name from table where rownum <=endIndex )   
    where rownum > startIndex 

 
 
二:DB2

DB2分页查询 

  SELECT * FROM (Select 字段1,字段2,字段3,rownumber() over(ORDER BY 排序用的列名 ASC) AS rn from 表名) AS a1 WHERE a1.rn BETWEEN 10 AND 20 

 

  以上表示提取第10到20的纪录 
  

select * from (select rownumber() over(order by id asc ) as rowid from table where rowid <=endIndex )   
    where rowid > startIndex 

 
   


三:MySQL: 

    select   *   from   table   limit   start,pageNum     

  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics