Home  >  Article  >  Database  >  ORACLE中SQL分页语句

ORACLE中SQL分页语句

WBOY
WBOYOriginal
2016-06-07 17:46:271397browse

下面简单的分享了几条ORACLE中SQL分页语句,有需要的朋友可参考参考。

下面简单的分享了几条ORACLE中SQL分页语句,有需要的朋友可参考参考。

最常用的是方法一:

 代码如下 复制代码

select * from (select ROWNUM as rn, Src.* from tab Src) DataSet Where rn> 10 and rn

方法二:

select * from (select ROWNUM as rn, Src.* from tab where rownum = 100;


结果发现由于该语句会先生成rownum 后执行order by 子句,因而排序结果根本不对,后来在GOOGLE上搜到一篇文章,原来多套一层select 就能很好的解决该问题,特此记录,语句如下:

 代码如下 复制代码

select * from

(select a.*,rownum row_num from

(select * from mytable t order by t.id desc) a

) b where b.row_num between 1 and 10

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn