The best solution : Use Index Hint ( you must already create the index on the column you want to sort )
Example:   SELECT   /*+ INDEX_ASC (Your_table your_index) */ 
            col1 , ...
   FROM     department
   where rownum <= 5 

解决方案 »

  1.   

    Another way ,
      write a PL/SQL block , define a cursor inside and loop it and fetch the first 5 records . It should be very fast .
      

  2.   

    SELECT   /*+ INDEX_ASC (Your_table your_index) */ 
                col1 , ...
       FROM     department
       where rownum <= 5 
    请问*+ INDEX_ASC (Your_table your_index) */ 是什么意思啊
      

  3.   

    select * from (select rownum as row_num,* from table) where row_num <6
      

  4.   

    /*+index_asc(your_table your_index)*/是指强制使用index,并且index按升序排列,这样query就能达到你所想要的结果。
    先create a index
    create index id_indx on dir_hotel(id);
    然后
    select /*+index_asc(dir_hotel id_indx)*/ * from dir_hotel where rownum<5
      

  5.   

    select * from ... where row_num <6;