ALTER_TABLESPACE(7pg14)

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

πŸ’… ALTER TABLESPACE πŸ’…

ok so this is the ALTER TABLESPACE page from the PostgreSQL 14.24 Documentation β€” yes, the whole manual, bestie, and we're gonna get through it together 🫢


✨ 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 [, ... ] )

look at her. four whole moods. pick one πŸ’…


🌸 DESCRIPTION 🌸

ALTER TABLESPACE is literally the glow-up command for a tablespace β€” you use it to change the definition of a tablespace. that's it, that's the vibe.

but listen, there's a gate πŸšͺ you must own the tablespace to change the definition of a tablespace. and if you're trying to alter the owner? you also have to be a direct or indirect member of the new owning role. (and yeah, superusers have these privileges automatically β€” main character energy, no cap πŸ‘‘)


πŸŽ€ PARAMETERS πŸŽ€

  • name β€” the name of an existing tablespace. the one you're messing with.
  • new_name β€” the new name of the tablespace. heads up though: the new name cannot begin with pg_, because those names are reserved for system tablespaces. don't even try it πŸ™ˆ
  • new_owner β€” the new owner of the tablespace. hand her over 🫢
  • 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. like, one disk is a sports car and the rest are shopping carts? tell the planner πŸŽοΈπŸ’¨

πŸ”₯ 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;

both iconic. both valid. go off ✨


πŸ’€ COMPATIBILITY πŸ’€

there is no ALTER TABLESPACE statement in the SQL standard. so if some other database is acting like this is normal β€” it's not, we're built different 😭


🌈 SEE ALSO 🌈


k that's the whole page, you ate that πŸ“ this was PostgreSQL 14.24, dated 2026, and it's the ALTER TABLESPACE(7) manual page β€” mwah, love u, go rename something πŸ’œπŸ§š

πŸ“¦ where this page comes from