Renz henry Espiritu
Renz henry Espiritu

Reputation: 1

How to get the specific rows of the table?

I am using Oracle database and I have a table that have 1.9 billion rows of records. I want to get the rows of records ranging from 100,000,001 to 200,000,000. Can someone help me on this? Thank you in advance.

Upvotes: 0

Views: 127

Answers (2)

Thiyagu ATR
Thiyagu ATR

Reputation: 2264

if you mean those ranges are rownum then here is simple the query

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

Upvotes: 0

DazzaL
DazzaL

Reputation: 21973

generally speaking you want a pagination query , which would be of the format:

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;

or

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

Upvotes: 2

Related Questions