The SQL used to write Oracle paging was:
(1)
SELECT *
From (select A.*, RowNum rnum
From (select ID, data
From T order by ID, ROWID) a
)
where Rnum >= 148 and rnum<=151;
Or
(2)
SELECT *
From (select A.*, RowNum rnum
From (select ID, data
From T order by ID, ROWID) a
where rownum <= 151)
where Rnum >= 148;
Recently in the development of colleagues said that the efficiency of the first (1) is not good, and the first (2) in a unique value (column) of the time to normal order, has been used in paragraph (1), today, colleagues find the following way to solve the first (2) Unique values (column) sorting problem, as follows:
(3)
SELECT *
From (select A.*, RowNum rnum
From (select ID, data
From T order by ID, rowid) A
where rownum <= 151)
where Rnum >= 148;
PS: The main is to add the rowid this field.
Reference website: http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
MyBatis Oracle Paging SQL