详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp53

[align=middle;" align="left] [size=11.5pt; font-family: 宋体; color: #333333;]标题:[/size][size=11.5pt; font-family: 宋体; color: #333333;]Oracle[/size][size=11.5pt; font-family: 宋体; color: #333333;]中的[/size][size=11.5pt; font-family: 宋体; color: #333333;]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]不能使用大于[/size][size=11.5pt; font-family: 宋体; color: #333333;]>[/size][size=11.5pt; font-family: 宋体; color: #333333;]的问题[/size]

[size=11.5pt; font-family: 宋体; color: #333333;]一、对[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]的说明[/size]

[size=11.5pt;" lang="EN-US]  [/size] [size=11.5pt; font-family: 宋体; color: #333333;]并非说用[/size][size=11.5pt;" lang="EN-US]“>[/size][size=11.5pt; font-family: 宋体; color: #333333;]、[/size][size=11.5pt;" lang="EN-US]>=[/size][size=11.5pt; font-family: 宋体; color: #333333;]、[/size][size=11.5pt;" lang="EN-US]=[/size][size=11.5pt; font-family: 宋体; color: #333333;]、[/size][size=11.5pt;" lang="EN-US]between..and”[/size][size=11.5pt; font-family: 宋体; color: #333333;]时会提示[/size][size=11.5pt;" lang="EN-US]SQL[/size][size=11.5pt; font-family: 宋体; color: #333333;]语法错误,而是经常是查不出一条记录来,还会出现似乎是莫名其妙的结果来。[/size]

[size=11.5pt;" lang="EN-US]   rowid[/size] [size=11.5pt; font-family: 宋体; color: #333333;]与[/size] [size=11.5pt;" lang="EN-US]rownum[/size] [size=11.5pt; font-family: 宋体; color: #333333;]虽都被称为伪列,但它们的存在方式是不一样的:[/size]

[size=11.5pt;" lang="EN-US]   rowid[/size] [size=11.5pt; font-family: 宋体; color: #333333;]相对于表来说又像表中的一般列,所以,以[/size] [size=11.5pt;" lang="EN-US]rowid[/size] [size=11.5pt; font-family: 宋体; color: #333333;]为条件就不会有[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]那些莫名其妙的结果出现。[/size]

[size=11.5pt;" lang="EN-US]  [/size] [size=11.5pt; font-family: 宋体; color: #333333;]对于下面的[/size][size=11.5pt;" lang="EN-US]SQL[/size][size=11.5pt; font-family: 宋体; color: #333333;]语句[/size]

[size=11.5pt;" lang="EN-US]    ROWNUM ID     AGE NAME

     ------- ------ --- ------[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]因为[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]总是从[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;]开始的,第一条不满足去掉的话,第二条的[/size][size=11.5pt;" lang="EN-US]rownum[/size] [size=11.5pt; font-family: 宋体; color: #333333;]又成了[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;]。依此类推,所以永远没有满足条件的记录。[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]它取得第一条记录则[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]值为[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;],第二条为[/size][size=11.5pt;" lang="EN-US]2[/size][size=11.5pt; font-family: 宋体; color: #333333;]。依次类推。[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]下条的[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]还会是[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;],又被删除,依次类推,便没有了数据。[/size]

[size=11.5pt;" lang="EN-US]

[/size][size=11.5pt; font-family: 宋体; color: #333333;]二、对[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]使用中几种现象的分析说明[/size][size=11.5pt;" lang="EN-US]

  

    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]有了以上从不同方面建立起来的对[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]的概念,下面认识使用[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]的几种现象[/size][size=11.5pt;" lang="EN-US]:[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]([/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;])[/size] [size=11.5pt;" lang="EN-US]select rownum,id,age,name from loaddata where rownum != 10[/size] [size=11.5pt; font-family: 宋体; color: #333333;]为何是返回前[/size][size=11.5pt;" lang="EN-US]9[/size][size=11.5pt; font-family: 宋体; color: #333333;]条数据呢?[/size][size=11.5pt;" lang="EN-US]

     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]为什么它与[/size] [size=11.5pt;" lang="EN-US]select rownum,id,age,name from loaddata where rownum [size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]也可以这样理解,[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]为[/size][size=11.5pt;" lang="EN-US]9[/size][size=11.5pt; font-family: 宋体; color: #333333;]后,取的记录的[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]为[/size][size=11.5pt;" lang="EN-US]10[/size][size=11.5pt; font-family: 宋体; color: #333333;],因条件为[/size] [size=11.5pt;" lang="EN-US]!=10[/size][size=11.5pt; font-family: 宋体; color: #333333;],所以删掉。然后取下一条,其[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]又是[/size][size=11.5pt;" lang="EN-US]10[/size][size=11.5pt; font-family: 宋体; color: #333333;],也删掉。以此类推。[/size]

[size=11.5pt;" lang="EN-US]

    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]([/size][size=11.5pt;" lang="EN-US]2[/size][size=11.5pt; font-family: 宋体; color: #333333;])什么[/size][size=11.5pt;" lang="EN-US]rownum >1[/size][size=11.5pt; font-family: 宋体; color: #333333;]时查不到一条记录,而[/size] [size=11.5pt;" lang="EN-US]rownum >0[/size][size=11.5pt; font-family: 宋体; color: #333333;]或[/size][size=11.5pt;" lang="EN-US]rownum >=1[/size] [size=11.5pt; font-family: 宋体; color: #333333;]却总显示所有记录。[/size]

[size=11.5pt;" lang="EN-US]

    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]([/size][size=11.5pt;" lang="EN-US]3[/size][size=11.5pt; font-family: 宋体; color: #333333;])为什么[/size][size=11.5pt;" lang="EN-US]between 1 and 10[/size] [size=11.5pt; font-family: 宋体; color: #333333;]或者[/size] [size=11.5pt;" lang="EN-US]between 0 and 10[/size] [size=11.5pt; font-family: 宋体; color: #333333;]能查到结果,而用[/size] [size=11.5pt;" lang="EN-US]between 2 and 10[/size] [size=11.5pt; font-family: 宋体; color: #333333;]却得不到结果。[/size]

[size=11.5pt;" lang="EN-US]

     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]从上可得[/size][size=11.5pt;" lang="EN-US],[/size][size=11.5pt; font-family: 宋体; color: #333333;]任何时候想把[/size][size=11.5pt;" lang="EN-US]rownum = 1[/size][size=11.5pt; font-family: 宋体; color: #333333;]这条记录抛弃是不对的。它在结果集中是不可或缺的。[/size]

[size=11.5pt;" lang="EN-US]

[/size][size=11.5pt; font-family: 宋体; color: #333333;]三、一些[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]实际运用的例子:[/size]

[size=11.5pt;" lang="EN-US]     -----------

      --sql[/size][size=11.5pt; font-family: 宋体; color: #333333;]建表脚本[/size]

[size=11.5pt;" lang="EN-US]     create table LOADDATA

      (

          ID   VARCHAR2(50),

          AGE  VARCHAR2(50),

          NAME VARCHAR2(50)

      );

      -----------[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]如果希望找到[/size][size=11.5pt;" lang="EN-US]loaddata[/size][size=11.5pt; font-family: 宋体; color: #333333;]表中第一条记录的信息,可以使用[/size][size=11.5pt;" lang="EN-US]rownum=1[/size][size=11.5pt; font-family: 宋体; color: #333333;]作为条件。[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]因为[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]都是从[/size][size=11.5pt;" lang="EN-US]“1”[/size][size=11.5pt; font-family: 宋体; color: #333333;]开始。[/size]

[size=11.5pt;" lang="EN-US]

       select rownum,id,age,name

       from loaddata

       where rownum = 1;   --[/size][size=11.5pt; font-family: 宋体; color: #333333;]可以用在限制返回记录条数的地方,保证不出错,如:隐式游标。[/size]

[size=11.5pt;" lang="EN-US]

     SQL>select rownum,id,age,name from loaddata where rownum = 1;[/size]

[size=11.5pt;" lang="EN-US]    ROWNUM ID     AGE NAME

     ------- ------ --- ------

          1 200001 22   AAA[/size]

[size=11.5pt;" lang="EN-US]

     SQL>select rownum,id,age,name from loaddata where rownum = 2;[/size]

[size=11.5pt;" lang="EN-US]    ROWNUM ID     AGE NAME

     ------- ------ --- ------[/size]

[size=11.5pt;" lang="EN-US]

   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]注:[/size][size=11.5pt;" lang="EN-US]SQL>select rownum,id,age,name from loaddata where rownum != 3; --[/size][size=11.5pt; font-family: 宋体; color: #333333;]返回的是前[/size][size=11.5pt;" lang="EN-US]2[/size][size=11.5pt; font-family: 宋体; color: #333333;]条记录。[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

     ------- ------ --- ------

          1 200001 22   AAA

          2 200002 22   BBB[/size]

[size=11.5pt;" lang="EN-US]

  [/size] [size=11.5pt; font-family: 宋体; color: #333333;]([/size][size=11.5pt;" lang="EN-US]2[/size][size=11.5pt; font-family: 宋体; color: #333333;])[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]对于大于某值的查询条件[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]原因是由于[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]是一个总是从[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;]开始的伪列,[/size][size=11.5pt;" lang="EN-US]Oracle[/size] [size=11.5pt; font-family: 宋体; color: #333333;]认为[/size][size=11.5pt;" lang="EN-US]rownum> n(n>1[/size][size=11.5pt; font-family: 宋体; color: #333333;]的自然数[/size][size=11.5pt;" lang="EN-US])[/size][size=11.5pt; font-family: 宋体; color: #333333;]这种条件依旧不成立,所以查不到记录。[/size]

[size=11.5pt;" lang="EN-US]    ROWNUM ID     AGE NAME

     ------- ------ --- ------[/size]

[size=11.5pt;" lang="EN-US]

    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]那如何才能找到第二行以后的记录?[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]注意子查询中的[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]必须要有别名,否则仍然会查不到记录,这是因为[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]不是某个表的列。[/size]

[size=11.5pt;" lang="EN-US]

      SQL>select rownum,id,age,name from(select rownum no ,id,age,name from loaddata) where no > 2;[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          3 200003 22   CCC

          4 200004 22   DDD

          5 200005 22   EEE

          6 200006 22   AAA[/size]

[size=11.5pt;" lang="EN-US]

      SQL>select * from(select rownum,id,age,name from loaddata) where rownum > 2;[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]([/size][size=11.5pt;" lang="EN-US]3[/size][size=11.5pt; font-family: 宋体; color: #333333;])[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]对于小于某值的查询条件[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]显然[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]对于[/size][size=11.5pt;" lang="EN-US]rownum[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          1 200001 22   AAA

          2 200002 22 BBB[/size]

[size=11.5pt;" lang="EN-US]

     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]综上几种情况:[/size]

[size=11.5pt;" lang="EN-US]     rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]对于大于某值的查询条件直接认为是[/size][size=11.5pt;" lang="EN-US]false[/size][size=11.5pt; font-family: 宋体; color: #333333;]的,但是可以间接的让它转为认为是[/size][size=11.5pt;" lang="EN-US]true[/size][size=11.5pt; font-family: 宋体; color: #333333;]的,那就必须使用子查询。[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]然后在主查询中判断新的[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]的[/size][size=11.5pt;" lang="EN-US]“[/size][size=11.5pt; font-family: 宋体; color: #333333;]别名列[/size][size=11.5pt;" lang="EN-US]”[/size][size=11.5pt; font-family: 宋体; color: #333333;]大于等于二的记录行。但是这样的操作会在大数据集中影响到检索速度。[/size]

[size=11.5pt;" lang="EN-US]

      SQL>select * from (select rownum no,id,age,name from loaddata where rownum = 2; --[/size][size=11.5pt; font-family: 宋体; color: #333333;]必须是里小外大[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          2 200002 22 BBB

          3 200003 22   CCC[/size]

[size=11.5pt;" lang="EN-US]

     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]也可以用这种方法实现[/size][size=11.5pt;" lang="EN-US]:[/size]

[size=11.5pt;" lang="EN-US]     SQL>select rownum,id,age,name from loaddata where rownum [size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]([/size][size=11.5pt;" lang="EN-US]4[/size][size=11.5pt; font-family: 宋体; color: #333333;])[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]和排序[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]前提条件:[/size][size=11.5pt;" lang="EN-US]loaddata[/size][size=11.5pt; font-family: 宋体; color: #333333;]表中已经[/size][size=11.5pt;" lang="EN-US]insert[/size][size=11.5pt; font-family: 宋体; color: #333333;]了[/size][size=11.5pt;" lang="EN-US]5[/size][size=11.5pt; font-family: 宋体; color: #333333;]条记录,最后一条记录[/size][size=11.5pt;" lang="EN-US]id[/size][size=11.5pt; font-family: 宋体; color: #333333;]是[/size][size=11.5pt;" lang="EN-US]200005[/size][size=11.5pt; font-family: 宋体; color: #333333;],接着[/size][size=11.5pt;" lang="EN-US]insert into loaddata values('200006','22','AAA');[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          1 200001 22   AAA

          2 200002 22   BBB

          3 200003 22   CCC

          4 200004 22   DDD

          5 200005 22   EEE

          6 200006 22   AAA[/size]

[size=11.5pt;" lang="EN-US]

      SQL>select rownum ,id,age,name from loaddata order by name;[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          1 200001 22   AAA

          6 200006 22   AAA

          2 200002 22   BBB

          3 200003 22   CCC

          4 200004 22   DDD

          5 200005 22   EEE[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]系统是按照记录插入时的顺序给记录排的号,[/size][size=11.5pt;" lang="EN-US]rowid[/size][size=11.5pt; font-family: 宋体; color: #333333;]也是顺序分配的。[/size]

[size=11.5pt;" lang="EN-US]     SQL>select rownum ,id,age,name from (select * from loaddata order by name);[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          1 200001 22   AAA

          2 200006 22   AAA

          3 200002 22   BBB

          4 200003 22   CCC

          5 200004 22   DDD

          6 200005 22   EEE[/size]

[size=11.5pt;" lang="EN-US]

     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]这样就成了按[/size][size=11.5pt;" lang="EN-US]name[/size][size=11.5pt; font-family: 宋体; color: #333333;]排序,并且用[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]标出正确序号(有小到大)。[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]同样,返回中间的记录集:[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          3 200002 22   BBB

          4 200003 22   CCC[/size]

[size=11.5pt;" lang="EN-US]

     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]一般业务需求中,是需要先排序后,再返回中间记录集:[/size]

[size=11.5pt;" lang="EN-US]     ROWNUM ID     AGE NAME

      ------- ------ --- ------

          3 200002 22   BBB

          4 200003 22   CCC[/size]

[size=11.5pt;" lang="EN-US]    [/size] [size=11.5pt; font-family: 宋体; color: #333333;]注意此时的[/size][size=11.5pt;" lang="EN-US]SQL[/size][size=11.5pt; font-family: 宋体; color: #333333;]语句写法,使用了多重(三层)嵌套。同时注意:[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]使用了[/size][size=11.5pt;" lang="EN-US]“[/size][size=11.5pt; font-family: 宋体; color: #333333;]列别名[/size][size=11.5pt;" lang="EN-US]”[/size][size=11.5pt; font-family: 宋体; color: #333333;]。[/size][size=11.5pt;" lang="EN-US]

 

     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]实际上,该语句也是[/size][size=11.5pt;" lang="EN-US]Oracle[/size][size=11.5pt; font-family: 宋体; color: #333333;]数据集一个经典的[/size][size=11.5pt;" lang="EN-US]SQL[/size][size=11.5pt; font-family: 宋体; color: #333333;]语句分页算法:先排序,再选择[/size][size=11.5pt;" lang="EN-US]rownum [/size] [size=11.5pt; font-family: 宋体; color: #333333;]某页的最小值。[/size]

[size=11.5pt; font-family: 宋体; color: #333333;]四、一个实例:[/size]

[size=11.5pt;" lang="EN-US]   [/size] [size=11.5pt; font-family: 宋体; color: #333333;]解:[/size][size=11.5pt;" lang="EN-US]rownum[/size][size=11.5pt; font-family: 宋体; color: #333333;]是伪列,在表里没有,数据库先是执行[/size][size=11.5pt;" lang="EN-US]from book[/size][size=11.5pt; font-family: 宋体; color: #333333;]遍历[/size][size=11.5pt;" lang="EN-US]book[/size][size=11.5pt; font-family: 宋体; color: #333333;]表。[/size]

[size=11.5pt;" lang="EN-US]       [/size] [size=11.5pt; font-family: 宋体; color: #333333;]如果有[/size] [size=11.5pt;" lang="EN-US]where[/size][size=11.5pt; font-family: 宋体; color: #333333;]条件,则不符合条件的就会从第一个结果集中删除,后面的数据继续加进来判断。[/size]

[size=11.5pt;" lang="EN-US]       [/size] [size=11.5pt; font-family: 宋体; color: #333333;]可以用一个子查询来解决这个问题:对于[/size][size=11.5pt;" lang="EN-US]select rownum,id from book where rownum=2;[/size] [size=11.5pt; font-family: 宋体; color: #333333;]是查不出数据来的。[/size]

[size=11.5pt;" lang="EN-US]

        declare

            v_number binary_integer;

            v_student student%rowtype;

        begin

            select count(*) into v_number from student;

            for i in 1..v_number loop

               select id,name,age into v_student from ( select rownum rn,id,name,age from student ) where rn=i;

               dbms_output.put_line('id: '||v_student.id||' name:'||v_student.name);

           end loop;

        end;[/size]

[size=11.5pt;" lang="EN-US]     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]简单的说[/size] [size=11.5pt;" lang="EN-US]rownum[/size] [size=11.5pt; font-family: 宋体; color: #333333;]是对符合条件结果的序列号。[/size]

[size=11.5pt;" lang="EN-US]     [/size] [size=11.5pt; font-family: 宋体; color: #333333;]它总是从[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;]开始排起的。所以,选出的结果不可能没有[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;],反而有其他大于[/size][size=11.5pt;" lang="EN-US]1[/size][size=11.5pt; font-family: 宋体; color: #333333;]的值。[/size]

[/align]

ORACLE ROWNUM解析的更多相关文章

  1. ORACLE ROWNUM解析[转]

    一.对rownum的说明 关于Oracle 的 rownum 问题,很多资料都说不支持SQL语句中的“>.>=.=.between...and”运算符,只能用如下运算符号“<.< ...

  2. Oracle rownum 分页, 排序

    Oracle rownum 分页, 排序 什么是rownum, rownum的生成, rownum相关的符号操作 Rownum是oracle生成结果集时得到的一个伪列, 按照读出行的顺序, 第一条ro ...

  3. Oracle硬解析,软解析,软软解析介绍

    Oracle数据库中的CURSOR分为两种类型:Shared Cursor 和 Session Cursor 1,Shared Cursor Oracle里的第一种类型的Cursor就是Shared ...

  4. Oracle游标解析

    本节对Oracle中的游标进行详细讲解. 本节所举实例来源Oracle中scott用户下的emp表dept表: 一.游标: 1.概念: 游标的本质是一个结果集resultset,主要用来临时存储从数据 ...

  5. 160628、利用Oracle rownum让表排序字段值连续

    利用Oracle rownum让表排序字段值连续 1.需求说明 表(eval_index)中有字段如下: 表字段 描述 说明 ID 主键 GROUP_ID 分组编号 SORT_NUM 排序序号 按照分 ...

  6. oracle数据库解析json格式

    随着非关系型数据大规模使用,以json格式产生的数据也出现在我所管理的Oracle数据库的CLOB字段里面,使用过程中就需要解析出指定键的值. 使用了最新版本 如果Oracle版本为12.1.0.2的 ...

  7. oracle rownum paging issues

    rownum是oracle预处理字段,默认标序是1,只有记录集已经满足条件后才会进行后续编号.由于第一条记录rownum默认是1,而你的条件是rownum>=6 对第一条记录比较它的rownum ...

  8. Oracle ROWNUM用法和分页查询总结(转)

    [转载] Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用. Oracle分页查询格式(一):http://yangtingkun.itpub.net/post/468/100278 ...

  9. Oracle SQL篇(三)Oracle ROWNUM 与TOP N分析

        首先我们来看一下ROWNUM: 含义解释: 1.rownum是oracle为从查询返回的行的编号,返回的第一行分配的是1,第二行是2,依此类推.这是一个伪列,可以用于限制查询返回的总行数. 2 ...

随机推荐

  1. JAVA多线程之Synchronized关键字--对象锁的特点

    一,介绍 本文介绍JAVA多线程中的synchronized关键字作为对象锁的一些知识点. 所谓对象锁,就是就是synchronized 给某个对象 加锁.关于 对象锁 可参考:这篇文章 二,分析 s ...

  2. 记Angular与Django REST框架的一次合作(1):分离 or 不分离,it's the question

    前言:本次尝试源于我们内部的一个项目,由于前端逻辑比较复杂,就打算将前后端分开来开发.由于之前用Django开发过软件,对Angular.js(Angular 1.0版)也有一定的了解,因此就将技术路 ...

  3. NYOJ--353--bfs+优先队列--3D dungeon

    /* Name: NYOJ--3533D dungeon Author: shen_渊 Date: 15/04/17 15:10 Description: bfs()+优先队列,队列也能做,需要开一个 ...

  4. 线索化二叉树的构建与先序,中序遍历(C++版)

    贴出学习C++数据结构线索化二叉树的过程, 方便和我一样的新手进行测试和学习 同时欢迎各位大神纠正. 不同与普通二叉树的地方会用背景色填充 //BinTreeNode_Thr.h enum Point ...

  5. 两个List比较各自对象的属性相同的问题

    最近做checkbox默认勾选的时候,涉及到两个list直接比较彼此对象的Id属性是否相同的问题.能力有限,想到这个笨方法. 创建一个Bean: public class Bean { private ...

  6. java实现网页爬虫

    接着上面一篇对爬虫需要的java知识,这一篇目的就是在于网页爬虫的实现,对数据的获取,以便分析. -----> 目录:   1.爬虫原理 2.本地文件数据提取及分析 3.单网页数据的读取 4.运 ...

  7. mysql 忘记root密码,重置密码,及重置密码后权限问题不能登录的解决方案

    由于一段时间没有使用MySQL,忘记了root登录密码. 决定重置下密码,搜索帮助. 参考文档: http://blog.csdn.net/odailidong/article/details/507 ...

  8. Linux - 简明Shell编程06 - 循环语句(Loop)

    脚本地址 https://github.com/anliven/L-Shell/tree/master/Shell-Basics 示例脚本及注释 #!/bin/bash # for循环 for fil ...

  9. TCP/IP小记

    --TCP/IP小记 -----------------2014/06/11 TCP的要求是:local_ip:local_port <==>remote_ip:remote_port这个 ...

  10. Mac terminal commands

    Mac terminal commands 1.install_name_tool修改dylib安装名称的命令 2.codesign 签名及查看 3.xcode 工程编译 4.程序打包app---&g ...