MOVE(7)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’… MOVE(7) β€” the postgres manual but make it make sense

okay so this is the MOVE(7) page from the PostgreSQL 14.24 Documentation, and honestly? it's a sleeper hit. bestie, it's short, it's sweet, and it does exactly one thing. let's get into it 🫢


✨ NAME ✨

MOVE β€” literally just position a cursor. that's it. that's the whole job. no rows come back, no drama, just vibes and placement πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

MOVE [ direction ] [ FROM | IN ] cursor_name

and direction can be any one of these iconic little numbers:

NEXT
PRIOR
FIRST
LAST
ABSOLUTE count
RELATIVE count
count
ALL
FORWARD
FORWARD count
FORWARD ALL
BACKWARD
BACKWARD count
BACKWARD ALL

like… the range? unmatched. 🌈


πŸ¦‹ DESCRIPTION πŸ¦‹

so MOVE repositions a cursor without retrieving any data. read that again. it moves the little guy around, but does NOT bring home the rows. it's giving "window shopping only" energy πŸ›οΈ

MOVE works exactly like the FETCH command, except β€” and this is the key part, iykyk β€” it only positions the cursor and does not return rows.

the parameters for MOVE are identical to those of the FETCH command, so if you want the full tea on syntax and usage, sprint over to FETCH(7). go go go πŸƒβ€β™€οΈπŸ’¨


🌸 OUTPUTS 🌸

on successful completion (slay), a MOVE command returns a command tag that looks like this:

MOVE count

and count is the number of rows that a FETCH command with the same parameters would have returned β€” (possibly zero). yes, zero is a valid answer, don't come for her πŸ™ˆ


πŸ“ EXAMPLES πŸ“

this is the part where we actually do the thing. buckle up, bestie:

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 what she did there? MOVE FORWARD 5 skipped five rows, then FETCH 1 grabbed the 6th. that's the whole trick. main character cursor energy πŸ‘‘


πŸ’€ COMPATIBILITY πŸ’€

not to be the bearer of bad news but… there is no MOVE statement in the SQL standard. she's built different. she's a PostgreSQL original. periodt πŸ’…


⭐ SEE ALSO ⭐

go read these next, they're all connected, it's a whole cinematic universe:


okay that's the page!! πŸ§šβ€β™€οΈπŸ’– this was brought to you by PostgreSQL 14.24, dated 2026, and the MOVE(7) manual page. now go forth and position your cursors responsibly. mwah πŸŽ€βœ¨πŸ«Ά

πŸ“¦ where this page comes from