MOVE(7)
π MOVE(7) β the PostgreSQL 13.23 docs, but make it group-chat
okay so bestie, this is MOVE(7) out of the PostgreSQL 13.23 Documentation and honestly? it's a tiny little icon and you're gonna love her.
β¨ NAME β¨
MOVE β position a cursor π―
π¦ SYNOPSIS π¦
MOVE [ direction ] [ FROM | IN ] cursor_name
and direction can be literally any one of these, no cap:
NEXT
PRIOR
FIRST
LAST
ABSOLUTE count
RELATIVE count
count
ALL
FORWARD
FORWARD count
FORWARD ALL
BACKWARD
BACKWARD count
BACKWARD ALL
πΈ DESCRIPTION πΈ
so MOVE repositions a cursor without retrieving any data π« like, it just... moves the little guy. that's it. that's the whole vibe.
MOVE works exactly like the FETCH command, except β and this is the key part β it only positions the cursor and does not return rows. so it's FETCH's chill sibling who shows up, adjusts the seating chart, and leaves without grabbing a single row. queen behavior honestly π
and the parameters for the MOVE command are identical to those of the FETCH command π«Ά so if you want the details on syntax and usage, go read FETCH(7). iykyk.
β OUTPUTS β
on successful completion, a MOVE command returns a command tag of the form:
MOVE count
and count is the number of rows that a FETCH command with the same parameters would have returned β possibly zero π (yes, zero counts as a valid answer, she's allowed to be zero, don't be weird about it).
π₯ EXAMPLES π₯
okay here's the whole little story, watch:
BEGIN WORK;
DECLARE liahona CURSOR FOR SELECT * FROM films;
-- Skip the first 5 rows:
MOVE FORWARD 5 IN liahona;
MOVE 5
-- Fetch the 6th row from the cursor liahona:
FETCH 1 FROM liahona;
code | title | did | date_prod | kind | len
-------+--------+-----+------------+--------+-------
P_303 | 48 Hrs | 103 | 1982-10-22 | Action | 01:37
(1 row)
-- Close the cursor liahona and end the transaction:
CLOSE liahona;
COMMIT WORK;
see how the MOVE FORWARD 5 IN liahona; skips the first 5 rows and then FETCH 1 FROM liahona; grabs the 6th? β¨ that's the whole trick. cursor named liahona, we stan a named cursor π
π COMPATIBILITY π
there is no MOVE statement in the SQL standard. none. she's built different. she's PostgreSQL's own thing π
π SEE ALSO π
go read all three, they're friends, they travel in a pack π«Ά
made with love by PostgreSQL 13.23, dated 2025, page MOVE(7) β and that's the whole manual page bestie, periodt π
π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql13 13.23-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms