1.运行时报错;
2.3选不出纪录。
只有SELECT * FROM table WHERE ROWNUM<10; 
才可以选出纪录。

解决方案 »

  1.   

    select * from (select * from table where rownum<=50000) where rownum>=10000;
    这种效率最高,但不能进行排序
    如果需要排序

    select * from (select * from (select * from tbname order by colname) where rownum<=50000) where rownum>=10000;
      

  2.   

    第一个只是多了一个分号而已
    SELECT * FROM table WHERE ROWNUM<101
    minus 
    SELECT * FROM table WHERE ROWNUM<91; 第三个肯定不行
      

  3.   

    刚试过了,select * from table1 where rownum between 90 and 100就可以了
    ROWNUM>90 AND ROWNUM<100的确不行
      

  4.   

    select * from table1 where rownum between 2 and 5
    在我这里还是不行啊。
    SELECT * FROM table WHERE ROWNUM<101
    minus 
    SELECT * FROM table WHERE ROWNUM<91; 
    正解!
      

  5.   

    难道和版本有关系?我的答案是
    select * from table1 where rownum between 2 and 5

    SELECT * FROM table WHERE ROWNUM<101
    minus 
    SELECT * FROM table WHERE ROWNUM<91; 
    都可以。我安装的是oracle上下载的oracle 9iR2
      

  6.   

    我经常用的是 bzszp(SongZip)介绍的方法,但也存在当数据量大(超过百万)时速度慢的问题,一次全查,一次排序,一次50000,一次10000,能不慢吗^_^
    第一种没用过,不知道效率如何,第三种是一种错误的理解不可取,
      

  7.   

    我的是8.1.7。
    select * from table1 where rownum between 2 and 5
    不行。
    看来是版本问题。
      

  8.   

    我的是8.1.7。
    select * from table1 where rownum between 2 and 5
    不行。
    看来是版本问题。
      

  9.   

    3解 的 和 between 
    在 8和8i下都不行
      

  10.   


     1. rownum的用法: 操作符只能用"<","=",不能用">". 因此,第三种
        方式是错误的
     2. Minus是返回查询区间,例如1里面的 rownum<101  minus rownum<91
        返回的是rownum=90-100之间的数据
     3. between 语句在9i可用,在8i(8.1.7.0)也可用.我测试过了. 4. 方法2在大数据量查询时确实效率很低,下面我贴一篇 
        ASKTOM.ORACLE.COM上提供的方法     获得查询结果
         select * from (select a.*, rownum r  from 
          (select * from t where x = :host_variable order by y ) a
           where rownum < :HigerBound )
           where r > :LowerBound      记住: 要用绑定变量来实现.     如果上面的代码执行太慢,可考虑下面的办法:         . 创建一个记录用户点击信息的表 hits
             create table hits( sess_id number, seqno number,
              rid rowid, primary key(sess_id,seqno));
            .. pass that userenv('sessionid') from page to page
               as a hidden variable then to identify the result set.           cnt := 0;
               for y in ( select t.rowid rid from t where x = :host_variable 
                   order by y ) 
               loop
                  cnt := cnt + 1;
                  insert into hits values ( userenv('sessionid'), cnt, y.rid);
               end loop;         ... query
              select * from t, hits
              where hits.seqno between :lowBound and :highBound
              and hits.sess_id = :theSessionId
              order by hits.sess_id, hits.seqno
          
              followup to comment one below         the rowid is simply a primary key.  Use the true primary key instead.
             Lets say you needed to do this for EMP and DEPT, you might do:         insert into hits
              select SESSION_ID, rownum, empno, deptno
              from ( select ename, dname
                    from emp, dept
                    where emp.deptno = dept.deptno
                    order by emp.ename );          Now, to display rows 100 - 110 you would:            select emp.ename, dept.dname
                from hits, emp, dept
                where emp.empno = hits.empno
                and dept.deptno = hits.deptno
                and sequence_col between :min and :max
                and session_id = :session_id;       You can use the rowids of the underlying tables as well.         说明: TOM给出的方法也用到了between,and,可见是可行的.