Oracle Series: (16) pagination

Source: Internet
Author: User


Review MySQL Paging

Use the Limit keyword


Querying the top two records in the Users table

SELECT * from Users limit 0,2

Or

SELECT * from users limit 2;

0 indicates the index number of the first record, and the index number starts at 0

2 indicates a maximum of two records selected


Check out the top three records of users

SELECT * from Users limit 0,3

Or

SELECT * From Users limit 3


Check out the records of users 2nd through 4th

SELECT * from Users limit 1, 3;



Review Hibernate paging API

Query.setfirstresult (0); Query.setmaxresult (3);






What is rownum, what is the characteristic

1) rownum is a key word dedicated to Oracle

2) rownum with the table, the table died it died, the table in it in

3) RowNum By default, it is not found in the table

4) Only in the SELECT clause, explicitly write out rownum to show

5) RowNum is the number type and the only continuous

6) The minimum value of rownum is 1 and the maximum value is the same as your record number

7) RowNum can also participate in relational operations

* rownum = 1 has value

* RowNum < 5 value

* rownum <=5 has value

* rownum > 2 No value

* RowNum >=2 No value

* rownum <>2 has the same value as RowNum < 2

* RowNum = 2 No value

8) based on rownum characteristics, we usually rownum only for < or <= relational operations


Displays 3-8 records in the EMP table (method One: Use Set subtraction)

Select RowNum "Pseudo-column", emp.* from EMP where Rownum<=8minusselect rownum,emp.* from EMP where rownum<=2;


Displays 2-8 records in the EMP table (way two: using subqueries, using in the FROM clause, emphasis)

Select Xx.*from (select RowNum ids,emp.* from emp where rownum<=8) xx where ids>=2;

Note: Aliases in subqueries are not added "" quotation marks

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/86/FD/wKiom1fQJQHT1mbwAABgngcHi5k999.png "title=" 007. PNG "alt=" Wkiom1fqjqht1mbwaabgngchi5k999.png "/>


displaying 5-9 records in the EMP table

Select Yy.*from (select RowNum ids,emp.* from emp where rownum<=9) Yywhere ids>=5;

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/86/FC/wKioL1fQJVThRWWEAAAix7ldCpQ105.png "title=" 008. PNG "alt=" Wkiol1fqjvthrwweaaaix7ldcpq105.png "/>

Note: In a project, there may be a real table name after from, or a table name that can be considered as a subquery.

A table to be considered as a real table and a subquery to make a connection query





Oracle Series: (16) pagination

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.