SQL 分页
- 
    常用分页,其中的 第二层的 rownum <= 20可以控制最内层查询过程中的最大记录数 select * from (select t1.*, rownum rn from (select * from table_buyer where buyer_status = 2 order by gmt_create desc) t1 where rownum <= 20) where rn >= 10;
- 
    分页用between实现 
 不推荐,因为第三层不能推到最内层控制查询条数,效率低select * from (select t.*, rownum rn from (select * from table_buyer where buyer_status = 2 order by gmt_create desc) t) where rn between 10 and 20;
- 
    效率最高 
 用rowid 分页,大数据量翻页常用写法,常用于单表,并且所有查询和排序字段都在索引中的情况select * from (select rid from (select t.rid, rownum linenum from (select rowid rid from table_buyer where buyer_status = 2 order by gmt_create desc) t where rownum <= 20) where linenum >= 10) t1, table_buyer t2 where t1.rid = t2.rowid;
…
This work is licensed under a CC A-S 4.0 International License.