MOVE(7)

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

πŸ’… 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