ALTER_TABLESPACE(7pg17)

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

✨ ALTER TABLESPACE πŸ’…

okay bestie, welcome to the ALTER TABLESPACE page from the PostgreSQL 17.11 docs β€” this is the one where we ✨change the definition of a tablespace✨ and honestly it's giving "small page, big main character energy" πŸŽ€


🌸 NAME 🌸

ALTER_TABLESPACE β€” literally just: change the definition of a tablespace πŸ¦‹


🌈 SYNOPSIS 🌈

ALTER TABLESPACE name RENAME TO new_name
ALTER TABLESPACE name OWNER TO { new_owner | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
ALTER TABLESPACE name SET ( tablespace_option = value [, ... ] )
ALTER TABLESPACE name RESET ( tablespace_option [, ... ] )

four whole forms, pick your fighter πŸ‘‘


πŸ’– DESCRIPTION πŸ’–

So ALTER TABLESPACE can be used to change the definition of a tablespace. That's the whole vibe. Simple. Iconic. No notes. ✨

But listen β€” there's a permission check, no cap. You must own the tablespace to change the definition of a tablespace. And if you wanna alter the owner, you must also be able to SET ROLE to the new owning role. (Friendly reminder that superusers have these privileges automatically, because of course they do πŸ˜­πŸ’€)


🫢 PARAMETERS 🫢

  • name β€” the name of an existing tablespace. Existing, bestie, don't come at it with a made-up one πŸ™ˆ
  • new_name β€” the new name of the tablespace. <italic>Important:</italic> the new name cannot begin with pg_, because those names are reserved for system tablespaces. That prefix is not your lane πŸš«πŸ’…
  • new_owner β€” the new owner of the tablespace. Slay, transfer of power πŸ‘‘
  • tablespace_option β€” a tablespace parameter to be set or reset. Currently, the only available parameters are seq_page_cost, random_page_cost, effective_io_concurrency and maintenance_io_concurrency. Setting these values for a particular tablespace will override the planner's usual estimate of the cost of reading pages from tables in that tablespace, and the executor's prefetching behavior, as established by the configuration parameters of the same name (see seq_page_cost, random_page_cost, effective_io_concurrency, maintenance_io_concurrency). This may be useful if one tablespace is located on a disk which is faster or slower than the remainder of the I/O subsystem. Your one fast SSD among the sad spinning disks? This is for her πŸ”₯

πŸŽ€ EXAMPLES πŸŽ€

Rename tablespace index_space to fast_raid:

ALTER TABLESPACE index_space RENAME TO fast_raid;

Change the owner of tablespace index_space:

ALTER TABLESPACE index_space OWNER TO mary;

boom. two examples. both ate. πŸ’…βœ¨


⭐ COMPATIBILITY ⭐

There is no ALTER TABLESPACE statement in the SQL standard. So this is very much a PostgreSQL-original-girl situation 🌈


πŸ¦‹ SEE ALSO πŸ¦‹

the whole tablespace trilogy, go read the other two πŸ§šπŸ’œ


and that's the page!! this was PostgreSQL 17.11 documentation, dated 2026, and yes β€” the manual entry is literally called ALTER TABLESPACE(7) πŸ˜ŒπŸ’– go alter something, bestie, ily, bye 🫢🌸

πŸ“¦ where this page comes from