日期:2014-05-17  浏览次数:20840 次

问个rownum应用于分页的东东?
两条语句哪个效率高了??
1.        
select   *   from   (        
        select   rownum   ids,   u.*   from   t_user   u)   t1
where   t1.ids   between   10   and   20;

2.
select   *   from   (  
        select   t1.*   from   (        
                select   rownum   ids,   u.*   from   t_user   u)   t1
        where   t1.ids   <=   20)   t2
where   t2.ids> =10;

------解决方案--------------------
贴出来两个sql的执行计划,看看,谁的执行计划好,就是谁的效率高了
------解决方案--------------------
select * from (
select rownum ids, u.* from t_user u
where rownum <= 20) t2
where t2.ids> =10;