What's the difference between FETCH FIRST and FETCH NEXT in PostgreSQL?
2
votes
1
answer
1285
views
What's the difference between
FETCH FIRST
and FETCH NEXT
in PostgreSQL? The docs simply say
> NEXT
> Fetch the next row
>
> FIRST
> Fetch the first row of the query
which isn't much of an explanation. I created a sample table with sample rows, executed
SELECT * from users
FETCH FIRST 2 ROWS ONLY;
SELECT * from users
FETCH NEXT 2 ROWS ONLY;
and got exactly the same output. It's almost as if FETCH FIRST
and FETCH NEXT
are merely synonyms for LIMIT
(which, I read, is not part of the SQL standard, unlike FETCH [FIRST|NEXT]
)
If the two are the same, why wouldn't the documentation say so? Or are there some differences after all?
This Stack Overflow answer implies they may function the same way in at least some RDBMSes, specifically in MS Server
Asked by Sergey Zolotarev
(243 rep)
Nov 5, 2023, 11:23 AM
Last activity: Nov 6, 2023, 03:54 PM
Last activity: Nov 6, 2023, 03:54 PM