Oracle分頁獲取資料時,資料重複錯亂問題

2021-10-08 19:47:42 字數 2039 閱讀 3864

今天測試出的乙個bug,差點坑到了,大概場景就是在oracle資料庫分頁查詢時,第一頁的資料和第二頁的資料重複率達到百分之70以上,開始以為是前端ui控制項重新整理問題,後面發現其實不是。簡單記錄下

select

*from

( select

a .*, rownum rn

from

(select

td_trade_participant. oid,

td_trade_participant. name,

td_trade_participant. account,

td_trade_participant.phone,

td_trade_participant.email,

td_trade_participant.country,

td_trade_participant.country_code,

td_trade_partner. name as main_unit,

td_trade_participant.user_id,

td_trade_partner. oid as main_unit_code,

td_trade_org. name as unit,

td_trade_org.code as unit_code,

td_trade_org.country as org_country,

td_trade_org.org_ship,

td_trade_org.org_ship_code,

td_trade_participant.activity_id,

td_trade_participant. type,

td_trade_participant.type_code,

td_trade_participant.status,

td_trade_participant.is_visible,

td_trade_participant. job,

td_trade_participant.certificatenum,

td_trade_participant.certificate_type,

td_trade_participant.accreditation_status,

td_trade_participant.***,

to_char (

td_trade_participant.sign_up_time,

'yyyy-mm-dd hh24:mi:ss:ff'

) as sign_up_time

from

td_trade_participant

left join td_trade_org on td_trade_org. oid = td_trade_participant.unit_code

left join td_trade_partner on td_trade_partner. oid = td_trade_participant.main_unit_code

and td_trade_partner.is_delete = '0'

where

td_trade_participant.is_delete = '0'

and td_trade_participant.activity_id = 'blt2t3q-qhoqr4dltwv7qw'

and td_trade_participant.status in ('3', '4')

order by

decode (

td_trade_participant.status,

'3',

1,'2',

2,'1',

3,'0',

4,'4',5)

) awhere

rownum <= 20

)where

rn >= 11

就是這麼個很簡單的多表查詢,經過檢查發現其實是由於後面的order by語句引起的,在後面排序語句上加上主鍵oid即可解決,具體的原因恐怕得去看oracle的內部設計了

獲取 rabbitmq 實時資料

以下列舉了一些典型的rabbitmq實時資料 獲取rabbitmq的consumer數目,以下為了節省空間,只顯示多少列,實際需要把列出的所有值相加 rabbitmqctl list channels consumer count listing channels 00 0031 31.rabbit...

oracle 表資料 誤刪時 資料恢復

通過時間恢復刪除資料 alter table drugusage enable row movement 開啟行遷移 select from drugusage as of timestamp to timestamp 2016 06 02 12 00 47 yyyy mm dd hh24 mi s...

oracle資料分頁

建立分頁過程 create or replace procedure fenye v tablename in varchar2,表名 v pagesize in number,每頁顯示的記錄數 v pagenum in number,當前頁碼 v countrows out number,總記錄數...