ALTER_TABLESPACE(7pg15)

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

✨ ALTER TABLESPACE ✨

okay bestie, so this is the ALTER TABLESPACE page from the PostgreSQL 15.19 docs, and honestly? it's a little guy but it does a LOT πŸ’… let's get into it.


🌸 NAME 🌸

ALTER_TABLESPACE β€” change the definition of a tablespace

like, you already made a tablespace and now you want to tweak it. that's the whole vibe check. πŸ¦‹


πŸŽ€ 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, no cap. pick your fighter. πŸ‘‘


πŸ’œ DESCRIPTION πŸ’œ

ALTER TABLESPACE can be used to change the definition of a tablespace. that's it, that's the job. ✨

now the important part (don't skip, bestie, this is the fine print that bites 😭): you must own the tablespace to change its definition. and if you wanna alter the owner, you also have to be a direct or indirect member of the new owning role. good news though β€” superusers get these privileges automatically, main character energy only πŸ’€


🌈 PARAMETERS 🌈

  • name β€” the name of an existing tablespace. existing, bestie. not one you're manifesting.
  • new_name β€” the new name of the tablespace. 🚨 and listen: the new name cannot begin with pg_, because those names are reserved for system tablespaces. respect the reserved prefix, periodt.
  • new_owner β€” the new owner of the tablespace. hand over the keys 🫢
  • tablespace_option β€” a tablespace parameter to be set or reset. rn 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. so like... fancy SSD tablespace gets different math than the sad old spinning disk one. iykyk πŸ“

⭐ 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;

look at mary, owning a tablespace. iconic. πŸ‘‘


🧚 COMPATIBILITY 🧚

there is no ALTER TABLESPACE statement in the SQL standard. nope. nada. we're off-book, bestie πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

the holy trinity of tablespace management fr fr ✨


cute little sign-off: this whole vibe is straight outta PostgreSQL 15.19, dated 2026, and the page is ALTER TABLESPACE(7). slay, go forth and manage your tablespaces responsibly πŸ’–
πŸ“¦ where this page comes from