选择表中的某一行记录:(理解:rownum是Oracle系统顺序分配为从查询返回的行的编号)
select * from (select rownum a,t.* from testtab t) where a=2;
select * from (select rownum a,t.* from testtab t) where a=3;
select * from (select rownum a,t.* from testtab t) where a=4;
不能为:
select * from (select rownum,t.* from testtab t) where rownum=2;或
select * from testtab where rownum=2;
返回多行记录:
select * from testtab where rownum19 and rownum
以为oracle是先提取记录再排序的,而oracle的rownum是在提取记录就已经生成,它先于排序操作,所以必须使用子查询先排序。
不能为:
select * from tsettab where rownum>10;
返回最后一行记录:
select * from (select rownum a,t.* from testtab t) where a=(select count(*) from testtab);
返回最后N行记录:
select * from (select rownum a,t.* from testtab t) where a=(select count(*)-N from testtab);
----------------
select * from adminrole where rownum