如何获取表的特定行?

时间:2013-04-04 09:44:09

标签: sql oracle oracle10g oracle11g between

我正在使用Oracle数据库,我有一个包含19亿行记录的表。我想获得100,000,001到200,000,000之间的记录行。有人可以帮我吗?提前谢谢。

2 个答案:

答案 0 :(得分:2)

一般来说,您需要一个分页查询,其格式为:

select t.*
   from (select t.*, rownum rn
           from (select t.yourfields
                   from yourtab t
                  order by t.something)
          where rownum <= end_rownum
        ) t
  where rn >= offset;

select *
  from (select t.yourfields, row_number() over (order by t.something) rn
          from yourtab t)
 where rn between start_rownum and end_rownum;

答案 1 :(得分:0)

如果你的意思是那些范围是rownum,那么这里的查询很简单

select * from (select e.*,rownum test from hr.employees e) where test>5 and test <50;