zoukankan      html  css  js  c++  java
  • oracle: Rownum原理

    Rownum原理:

    1 Oracle executes your query.

    执行查询操作

    2 Oracle fetches the first row and calls it row number 1.

    将第一行的row num置为1

    3 Have we gotten past row number meets the criteria? If no, then Oracle discards the row, If yes, then Oracle return the row.

    将得到的行的row num与条件相比较,如果不匹配,则抛弃行,如果匹配,则返回行

    4 Oracle fetches the next row and advances the row number (to 2, and then to 3, and then to 4, and so forth).

    oracle获取下一行,然后将rownum增1

    5 Go to step 3.

    返回第3步

     

    从这个原理可以知道,select rownum,name from emp where rownum>5;不返回行,因为首先执行查询select name from emp,将第1行的rownum标为1,然后看where条件,为false,则抛弃行,执行第2行,还是rownum标为1,看where条件还为false,所以永远是false,rownum不改变,所有的行都被抛弃,所以没有结果。

    where rownum = n(n>1)

    where rownum > n 都不可用,也就是上面的原因

  • 相关阅读:
    制造者为什么重要
    归因理论
    初创业谨记有三法宝:顶梁柱、现金牛、北极星
    华特迪士尼语录
    说好一个创业故事的5个步骤
    接口
    抽象类_模板方法设计模式
    抽象类与抽象方法
    非static和static初始化块
    单例设计模式
  • 原文地址:https://www.cnblogs.com/mpxBlog/p/5909288.html
Copyright © 2011-2022 走看看