使用oracle SQL显示表中的一系列行

时间:2013-05-21 21:52:16

标签: sql oracle

我需要从表'customers'中显示256到700行。 Customers表可以包含数百万行。 Customers表具有在'cust_id'

上定义的主键

1 个答案:

答案 0 :(得分:1)

可能最快的方法就是这样:

select c.*
from (select rownum as seqnum, c.*
      from customers c
      where rownum <= 700
     ) c
where seqnum >= 256;

唯一需要注意的是,select查询中未定义行的顺序。要按正确的顺序排列,您应该使用:

select c.*
from (select rownum as seqnum, c.*
      from (select c.*
            from customers c
            order by cust_id
           ) c
      where rownum <= 700
     ) c
where seqnum >= 256;