内容简介:问题:今天在工作中,在service中调用分页查询列表接口的时候,返回的到页面的数据中总是存在缺失的数据,还有重复的数据。分析:select * from (select ROWNUM rn,t.* from (select * from student order by class) t where ROWNUM <![CDATA[<]]>#{1.endIndex}) where rn <![CDATA[>=]]>#{1.startIndex}当endIndex为3和为5的时候ROWNUM发生了变化
问题:今天在工作中,在service中调用分页查询列表接口的时候,返回的到页面的数据中总是存在缺失的数据,还有重复的数据。
分析:select * from (select ROWNUM rn,t.* from (select * from student order by class) t where ROWNUM #{1.endIndex}) where rn =]]>#{1.startIndex}
当endIndex为3和为5的时候ROWNUM发生了变化
|
id |
student |
class |
rownum |
|
1 |
zhao |
2 |
1 |
|
2 |
qian |
2 |
2 |
|
3 |
li |
2 |
3 |
|
id |
stuent |
class |
rownum |
|
1 |
zhao |
2 |
1 |
|
3 |
li |
2 |
2 |
|
4 |
song |
2 |
3 |
|
2 |
qian |
2 |
4 |
|
5 |
yang |
2 |
5 |
在上表中qian 和li 的rownum发生了变化
总结:Oracle分页语句中:
1 不存在order by 则系统根据rowid来排序
2 若存在order by 则order by 后面的限制的列必须要能确定唯一,或者最小粒度的列能确定唯一(如id列)如上class都相同,则可以加上
order by class,id 或者 order by class,rowid
更多Oracle相关信息见 Oracle 专题页面 https://www.linuxidc.com/topicnews.aspx?tid=12
Linux公社的RSS地址 : https://www.linuxidc.com/rssFeed.aspx
本文永久更新链接地址: https://www.linuxidc.com/Linux/2019-04/158392.htm
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Learn Python the Hard Way
Zed Shaw / Example Product Manufacturer / 2011
This is a very beginner book for people who want to learn to code. If you can already code then the book will probably drive you insane. It's intended for people who have no coding chops to build up t......一起来看看 《Learn Python the Hard Way》 这本书的介绍吧!