Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2003
    Posts
    52

    Unanswered: Select n rows from table

    I have two requests 'cos Im new in Oracle

    how can l get the first n registers from a table

    and where can i get a manal of al specification of oracle

    Regards

  2. #2
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    select *
    from table
    where rownum <=10;

    Documentation:
    http://otn.oracle.com/documentation/index.html
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  3. #3
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    In any RDBMS there are no "first" row(s).
    First based upon which metric?
    http://tahiti.oracle.com contains many Oracle manuals

  4. #4
    Join Date
    Nov 2003
    Posts
    52
    ThanX!!!!!

  5. #5
    Join Date
    Mar 2002
    Location
    Reading, UK
    Posts
    1,137
    try

    select * from
    (
    select * from table order by x
    )
    where rownum<10

    should work in all recent versions of oracle 8i, 9i etc, may have issues with 7 or 8.0.

    Alan

  6. #6
    Join Date
    Jan 2004
    Location
    Leiden, The Netherlands
    Posts
    11
    There is no 'natural' order in an Oracle table. A select without 'order by' will give you the results in a random order and not the order of your 'inserts'. Oracle sometimes moves records around.

    example

    insert into test values (1);
    insert into test values (2);
    insert into test values (3);
    insert into test values (4);

    could give:

    select * from test;

    3
    4
    1
    2

    select * from test where rownum <=3;

    will give

    3
    4
    1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •