MOVE(7)
๐ 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
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- opensuse-leap 16.0: postgresql18 18.6-160000.1.1 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms