zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

oracle分页基本语法[通俗易懂]

Oracle 通俗易懂 基本 分页 语法
2023-06-13 09:11:45 时间

大家好,又见面了,我是你们的朋友全栈君。

–分页: –mysql: limit –oracle:rownum伪列 –伪列:在表结构中不存在的列 –rowid伪列:用于唯一标识一行记录 –rownum伪列:行号

select * from emp;–看不到行号 –select *,rownum from emp;–报错

select e.*,rownum from emp e;–正确的

–rownum:行号是从1开始的,也就是有了1才会有2 select e.*,rownum from emp e where rownum=2;–获取不到数据

–分页 –每页显示2条,显示第2页的数据 –pageIndex:第几页(当前页码) –pageSize:每页显示的记录数 –startRow:(pageIndex-1)*pageSize==>(2-1)2==>2 –endRow:pageIndex*pageSize==>2*2=4 –select * from emp where rownum>startRow and rownum<=endRow /* select * from( select e.*,rownum from emp e where rownum<=endRow )tmp where tmp.rownum>startRow */ select e.*,rownum from emp e; select * from ( select e.*,rownum rn from emp e where rownum<=4 ) tmp where tmp.rn>2;

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/140270.html原文链接:https://javaforall.cn