Help Center/
GaussDB/
Developer Guide(Centralized_8.x)/
SQL Reference/
SQL Syntax/
S/
SELECT/
Pagination Queries
Updated on 2024-06-03 GMT+08:00
Pagination Queries
The syntax is as follows:
SELECT query_list FROM table_name [ LIMIT { [offset,] count | ALL } ]
- offset: indicates the number of rows to skip before starting to return rows.
- count: indicates the number of data records to be retrieved after the skipped rows.
- ALL: indicates that all data after the skipped rows is retrieved.
-- Create a table and insert 100 data records into the table. gaussdb=# CREATE TABLE testl(id int PRIMARY KEY, flag varchar(10)); gaussdb=# INSERT INTO testl (id, flag) VALUES (generate_series(1,100),'flag'||generate_series(1,100)); -- Query the first five data records. gaussdb=# SELECT * FROM testl ORDER BY 1 LIMIT 5; id | flag ----+------- 1 | flag1 2 | flag2 3 | flag3 4 | flag4 5 | flag5 (5 rows) -- Query four data records after the twentieth record. gaussdb=# SELECT * FROM testl ORDER BY 1 LIMIT 20,4; id | flag ----+-------- 21 | flag21 22 | flag22 23 | flag23 24 | flag24 (4 rows) -- Query all data after the ninety-sixth record. gaussdb=# SELECT * FROM testl ORDER BY 1 LIMIT 96,ALL; id | flag -----+--------- 97 | flag97 98 | flag98 99 | flag99 100 | flag100 (4 rows) -- Delete. gaussdb=# DROP TABLE testl;
Parent topic: SELECT
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot