Page has been a popular relational database, in very large amounts of data, the need to page display, showing the number of records per page, in order to reduce the pressure data;
1 implementation principle, according to the number of records rownum taken, according to the formula (Page 1) * the number of pages per recording AND * want to show the number of records, where the number of pages is a variable, the number of records is a constant, a filter ROWNUM field.
The following SQL to achieve a number of pages to check records, and how many of each page specified number of records;
T. * FROM the SELECT
(. The SELECT ROWNUM the AS the RN, * FROM table name table) T
the WHERE the RN the BETWEEN (Page 1) * * Recording +1 AND record number of pages;
Example: a lookup table DBA_USERS, watch the amount of data a total of 36, paged, each page 12 shows, SQL as follows:
SELECT &A,
RN,
USERNAME,
USER_ID,
DEFAULT_TABLESPACE
FROM (SELECT ROWNUM AS RN,
USERNAME,
USER_ID,
DEFAULT_TABLESPACE
FROM DBA_USERS)
WHERE RN BETWEEN (&A - 1) * 12 AND (&A) * 12;
当&A=1;
当&A=2: