MOVE(7)

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

πŸ’… MOVE (7) β€” like, position a cursor, bestie

okay so this one is from the PostgreSQL 17.11 docs and it's genuinely so chill β€” no cap, MOVE is the low-key sibling of FETCH and it literally just... points the cursor somewhere. that's it. that's the whole vibe. ✨


🌸 NAME 🌸

MOVE β€” position a cursor 🎯


✨ SYNOPSIS ✨

MOVE [ direction ] [ FROM | IN ] cursor_name

where direction can be one of these icons πŸ‘‡ (yes, all of them, I'm not skipping a single one):

    NEXT
    PRIOR
    FIRST
    LAST
    ABSOLUTE count
    RELATIVE count
    count
    ALL
    FORWARD
    FORWARD count
    FORWARD ALL
    BACKWARD
    BACKWARD count
    BACKWARD ALL
  • 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 and retrieves zero data. like, it's giving "I'm just here to move, not to fetch" energy πŸ’…. MOVE works exactly like the FETCH command, except β€” huge difference, bestie β€” 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 details on syntax and usage you gotta refer to FETCH(7). iykyk 🫢


πŸŽ€ OUTPUTS πŸŽ€

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

MOVE count

the count is the number of rows that a FETCH command with the same parameters would have returned (possibly zero). yes, possibly zero β€” she can absolutely return nothing and still slay πŸ’€


πŸ”₯ EXAMPLES πŸ”₯

here's the whole little scenario, verbatim, eat it up πŸ“:

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;

look at that cursor named liahona living her best main character life πŸ˜­πŸ‘‘


πŸ’€ COMPATIBILITY πŸ’€

there is no MOVE statement in the SQL standard. periodt. so if some standard-conformance checker comes for you, that's the tea πŸ™ˆ


🌈 SEE ALSO 🌈


fr fr, go read FETCH(7) β€” MOVE is literally the same parameter list, she just refuses to hand over the rows πŸ’œ

okay bye bestie, this page was PostgreSQL 17.11, dated 2026, and it's literally iconic β€” see you in the next manpage πŸ§šβœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from