数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

利用SQL语句对不同数据库进行高效果分页[2]


发布日期:2018年03月01日
 
利用SQL语句对不同数据库进行高效果分页[2]

Oracle数据库

因为Oracle数据库没有Top关键字所以这里就不能够像微软的数据据那样操作这里有两种方法

()一种是利用相反的

PAGESIZE每页显示的记录数

CURRENTPAGE当前页号

数据表的名字是components

索引主键字是id

select * from components where id not

in(select id from components where

rownum<=(PAGESIZE*(CURRENTPAGE)))

and rownum<=PAGESIZE order by id;

如下例

select * from components where id not in

(select id from components where rownum<=)

and rownum<= order by id;

到记录开始选择选择前面

()使用minus即中文的意思就是减去

select * from components where rownum

<=(PAGESIZE*(CURRENTPAGE)) minus

select * from components where rownum

<=(PAGESIZE*(CURRENTPAGE));

如例select * from components where

rownum<= minus select * from components

where rownum<=;

()一种是利用Oracle的rownum这个是Oracle查询自动返回的序号一般不显示但是可以通过select rownum from [表名]看到注意它是从到当前的记录总数

select * from (select rownum tidcomponents

* from components where rownum<=) where tid<=;

[] []

               

上一篇:利用SQL语句对不同数据库进行高效果分页[1]

下一篇:PB环境下分布式应用程序的开发(一)