MOVE(7)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’– MOVE(7) ๐Ÿ’–

okay bestie, welcome to the MOVE page from the PostgreSQL 18.6 Documentation โœจ this one is short, sweet, and honestly iconic โ€” it's the "just move, don't touch anything" of SQL. ๐ŸŽ€


โœจ NAME โœจ

MOVE โ€” position a cursor ๐Ÿ’…


๐Ÿฆ‹ SYNOPSIS ๐Ÿฆ‹

MOVE [ direction ] [ FROM | IN ] cursor_name

and where direction can be one of:

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

like yes, that's a lot of directions, but she contains multitudes. ๐ŸŒˆ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

so MOVE repositions a cursor without retrieving any data. that's the whole personality. no rows, no drama, just vibes and a new position. ๐Ÿ’…

MOVE works exactly like the FETCH command, except โ€” and this is the key part, no cap โ€” it only positions the cursor and does not return rows. it's giving "we're going there, but we're not unpacking." ๐Ÿงš

the parameters for MOVE are identical to those of FETCH, so if you need the details on syntax and usage, go read FETCH(7). she's the main character, this one is her quieter sibling. ๐Ÿซถ


โญ OUTPUTS โญ

when it works (and bestie, it will), a MOVE command returns a command tag that looks like this:

MOVE count

and count here is the number of rows that a FETCH command with the same parameters would have returned โ€” which, yes, can possibly be zero. zero is still a valid count, she's valid. ๐Ÿ’–


๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

here's the whole situation in action:

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 MOVE FORWARD 5 IN liahona; just said MOVE 5 and dipped? no rows returned, cursor moved, we move on. that's the whole point. ๐Ÿ‘‘


๐Ÿ’€ COMPATIBILITY ๐Ÿ’€

there is no MOVE statement in the SQL standard. she's built different. she's not in the group chat. periodt. ๐Ÿ˜ญ


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘


and that's the page!! ๐ŸŒŸ this was PostgreSQL 18.6, dated 2026, and the page is MOVE(7) โ€” mwah, tysm for reading, go position a cursor responsibly, ily bestie ๐Ÿ’œ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from