PostgreSQL 10 pagination

Source: Internet
Author: User
Tags postgresql

Example:

select * from test limit 2 offset 2;

Limit: How many data are checked
Offset: Starting from the subscript, the subscript starts at 0 and cannot be a negative number.
Offset Calculation formula:

var offset=(pageIndex-1) * pageSize // pageIndex must be greater than 0

Note: Limit and offset do not need to exist at the same time (this is more interesting)

1. Check the first 2 data

Specify limit, no offset specified, default offset=0

select * from test limit 2;

2. Skip the previous 2 data to check all the data behind

Specifies offset, without specifying limit,limit= infinity or No

select * from test offset 2;


select * from test offset 0;  / * Check all data, equivalent to select * from test * /

PostgreSQL 10 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.