rownum工作原理.
Rownum原理:
1 Oracle executes your query.
1.执行查询操作
2 Oracle fetches the first row and calls it row number 1.
2.将第一行的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.
3.将得到的行的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).
4.oracle获取下一行,然后将rownum增1
5 Go to step 3.
5.返回第3步我的疑问是:如何理解 select rownum,name from emp where rownum>5;不返回行
Rownum原理:
1 Oracle executes your query.
1.执行查询操作
2 Oracle fetches the first row and calls it row number 1.
2.将第一行的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.
3.将得到的行的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).
4.oracle获取下一行,然后将rownum增1
5 Go to step 3.
5.返回第3步我的疑问是:如何理解 select rownum,name from emp where rownum>5;不返回行
---我的疑问是:如何理解 select rownum,name from emp where rownum>5;不返回行select rownum,name from emp where rownum>5
--这样写是错的 在里面只能是rownum<=nselect * from (select rownum rn,name from emp where rownum<=n)
where rn>5
--嵌套才能这样的
rownum是不能用来判断rownum>n的,
如果想用rownum大于几判断的话需要子查询
select rm,字段1 from (select rownum rm,字段1 from 表名) where rm>5;
恩 学习了 rownum>=1时,全部记录,但是改为rownum>1就没有记录了。