mysql中的sql语句:

select * from 表名 limit 0,10;

换成Oracle,相应功能的语句为:表示取表中的前10条数据(从第1条开始,取10条)

select * from 表名 where rownum <= 10 ;

如果取[5,10]条,则,oracle语句写法有两种:

(1)
select   *   from   table   where   rownum<=10 
minus
select   *   from   table   where   rownum<5 ;
(2) 
select * 
from ( select rownum r,a.* 
       from table a 
       where rownum<=10 ) 
where r>=5;
因为rownum不支持>=操作,所以,要先将rownum实例化。
经测试,第二种写法,比第一种写法的效率要高。

 

相关文章:

  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-12-18
  • 2021-11-20
  • 2021-09-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-06
  • 2021-06-18
  • 2022-12-23
  • 2021-11-19
  • 2021-04-17
相关资源
相似解决方案