zoukankan      html  css  js  c++  java
  • Oracle分页查询

    select * from teacher where tno>1090

    --回忆之前的MYSQL分页
    select * from teacher limit (pageIndex-1)*pageSize,pageSize

    --oracle的分页 需要伪列? 什么是伪列!
    --伪列 可以从表中查询的到!每个表都有这个伪列!但是不能对伪列
    --进行增删改操作!伪列的值是不允许被改变的
    --rowid:存储的是表中行的存储地址,是唯一的!可以使用rowID定位到表中的一行
    --增长的规律: 最后一个字母。默认从A开始 A-Z a-z 0-9 + / 倒数第二位变成B
    --rownum:返回的是查询结果中 行的序号!
    --rownum只能对=1或者<n进行筛选,不能对>n进行筛选
    --如果想使用>n来查询,那么必须通过子查询建立临时表,
    --然后让rownum成为临时表中的列,然后限定条件使用伪列的别名

    --查询教师表中的薪水最高前5名
    select * from
    (select * from teacher
    order by sal desc)
    where rownum<6


    --查询教师表中的薪水第5名
    select * from(
    select t.*,rownum rw from
    (select * from teacher order by sal desc) t
    )
    where rw=5

    --使用分析函数 排序
    select * from
    (
    select t.*,dense_rank() over(order by sal desc) rank
    from teacher t
    )
    where rank=5


    --查询 教师表中的薪水最高5 -9
    select * from(
    select t.*,rownum rw from
    (select * from teacher order by sal desc) t
    )
    where rw>=5 and rw<=9

      (以上内容来自王硕老师)

  • 相关阅读:
    Python常用函数
    Mock测试&Postman mockserver详细教程
    openpyxl模块
    adb 'grep' 不是内部或外部命令,也不是可运行的程序或批处理文件
    Appium-Python-Windows环境搭建笔记
    调用类方法时报错:missing 1 required positional argument: 'self'
    RE正则表达式-元字符
    微分方程
    操作系统学习记录
    Mybatis基础配置
  • 原文地址:https://www.cnblogs.com/liu-chao-feng/p/5890346.html
Copyright © 2011-2022 走看看