1 rownum 分页
(select * from emp)
2 显示rownum[orcale分配的]
select a1.*,rownum rn from (select * from emp) a1;
3假如选择rn为6-10的话就先选择<10的,然后再选择>6的(oracle中的rownum只能用一次而不能像'rownum>10 and rownum<6'这么用)
select a1.* from rownum rn from (select * from emp) a1 where rownum<=10; -----先选择<10的列
4再选择>6的列
select * from (select a1.*,rownum rn (select * from emp) a1 where rownum<10) where rn>6; ----rownum格式只能这样表示不能有and注意里面的用rownum<10 外面的用 rn>6 如果想改变现实的字段只需要改变最内层的select就行了
根据ROWID来分
select * form t_xiaoxi where rowid in(select rid from (select rownum rn,rid from(select rowid rid ,cid from t_xiaoxi order by cid desc ) where rownum<10000) where rn>9980) order by cid desc; ----cid列明这种方法耗时最短
根据ROWNUM ---速度适中
select * from(select t.*,rownum rn from(select * from t_xiaoxi order by cid desc) t where rownum<10000) where rn>9980;
按分析函数来分 ---耗时最长
select * from (select t.*,row_number() over(order by cid desc) rk from t_xiaoxi t) where rk<10000 and rk>9980;