oracle数据库分页

oracle不像mysql有limit分页函数,只能借助于rownum来进行分页。使用rownum分页一共有三种写法。

第一种:

select   *   from   table   where   rownum<11     
  minus     
select   *   from   table   where   rownum<1

第二种:

 select * from (select rownum rn,a.* from SYS_OP_LOG a where rownum<11) where rn>=1; 

第三种:

select * from (select rownum rn,a.* from SYS_OP_LOG a) where rn between 1 and 10; 

这三种方式都可以用来进行数据库分页,由于表里的数据较少,只有几千条,查询效率几乎看不出差别。但是理论上的话,第二种写法要快一点,因此推荐第二种写法

你可能感兴趣的:(oracle)