zoukankan      html  css  js  c++  java
  • Oracle Pagination

    rownum为虚拟列,不是实际物理列

    select rownum,t.code from sys_config t; // 取得行数和code列

    select rownum, t.code from sys_config t where rownum <=20 order by t.code; // 取得行数<=20,并按code排序,排序失败

    select rownum, code from (select * from sys_config order by code) where rownum <=20; // 取得前20行成功

    select rownum, code from (select * from sys_config order by code) where rownum>=1 and rownum <=20; // 取得1到20行成功

    select rownum, code from (select * from sys_config order by code) where rownum>=2 and rownum <=20; // 取得2到20行失败

    select rn,code from (select rownum as rn,code from (select * from sys_config order by code)) where rn >=2 and rn <=20; // 取得2到20行成功

    最后一行为分页查询SQL语句,其他分页语句:
    select * from (select rownum as rn, T.* from (select * from table_name) T where rownum<40) where rn>21; // 效率高些
    select * from (select rownum as rn, T.* from (select * from table_name) T) where rn between 20 and 40; // 效率低些

    参考连接文章:

    http://database.51cto.com/art/201106/270156.htm

    http://database.51cto.com/art/200904/118737.htm

    路慢慢其休远羲,吾将上下而求所
  • 相关阅读:
    Python 基础(二)
    Python 入门
    DNS
    PXE自动化安装CentOS7和CentOS6
    AIDE及sudo应用
    SSH应用
    KickStart自动化安装Linux
    初见鸟哥
    数组ARRAY
    SSH用法
  • 原文地址:https://www.cnblogs.com/garinzhang/p/2814261.html
Copyright © 2011-2022 走看看