|
【赛迪网-it技术报道】虽然oracle数据库并不支持top关键字:但它提供了rownum这个隐式游标,可以实现与top类似的功能。
示例如下:
select top 10 ... from where ...
要写成
select ... from ... where ... and rownum <= 10
rownum 是记录序号(1,2,3...),注意:如果 sql 语句中有 order by ... 排序的时候,rownum 居然是先“标号”后排序!这样,这个序号如果不加处理是不合乎使用需求的。
至于临时表,oracle数据库的临时表和sql server的有很大不同。
分页示例:
select * from
(
select a.*, rownum r
from
(
select *
from articles
order by pubtime desc
) a
where rownum <= pageupperbound
) b
where r > pagelowerbound;
|