rowid是物理存储,rownum记录行数.

解决方案 »

  1.   

    如下:
    select id,rownum from tablename order by number
    结果如下:
    id              rownum3                 6
    5                 5 
    31                24
    7                 12
    9                 11
    12                32
    34                65
    ......
    但是我想每次取出5条
    但是这样写无效:
    select id,rownum from tablename where rownum>=1 and rownum<6又什么好的方法做到每次只取5条?
    请指教:
      

  2.   

    意思是前五条吧?
    select id,rownum from (select * tablename order by number) where rownum<=5;
      

  3.   

    select id,rowno from (select rownum rowno,tablename.* from tablename ) where rowno>10 and rowno<16; //11-15条,自己改吧
      

  4.   

    select * from (select rownum rm,a.* from tablename a order by number) where rm<=m and rm>=n;不明白表达的一次往后推是什么意思?
      

  5.   

    to :bzszp
    按照你的方法当然可以取出数据,但是取出来的数据是表中的物理顺序
    而我要求是排序之后的顺序,所以。
      

  6.   

    declare
    cursor t_sor(a number,b number) is
    select * from (select rownum rm,AA.* from tablename AA order by number) where rm<=a and rm>=b;
    m number:=1;
    n number:=5;
    begin
    for num in m..n loop
    for v_sor in t_sor loop
    .......
    end loop;
    m:=m+5;
    n:=n+5;
    end loop;
    end;  
      

  7.   

    sorry,修改以下:for v_sor in t_sor(m,n) loop
    .......
    end loop;