zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

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

2023-04-18 15:54:01 时间

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

Oracle分页查询写法:

一:Oracle

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

二:DB2

DB2分页查询

  1. 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的纪录

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

三:MySQL:

  1. select   *   from   table   limit   start,pageNum     

 

 

 

 

【编辑推荐】

两种DB2分区数据库恢复方式

三类DB2数据库备份方案

在线改变DB2页大小的实现

windows下创建DB2表空间的过程

DB2字符串连接的实现过程