ALTER_TABLESPACE(7pg16)

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

πŸ’« ALTER TABLESPACE πŸ’«

okay so bestie, welcome to ALTER TABLESPACE(7) β€” that's the PostgreSQL 16.15 documentation page for the statement that lets you change the definition of a tablespace. Tablespace glow-ups, basically. Renting out new real estate, renaming the place, handing over the keys. 🏠✨


✨ SYNOPSIS ✨

Here's the whole vibe in four lines, no cap:

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

Pick your fighter: rename it, re-own it, set some options, or reset some options. Slay. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

ALTER TABLESPACE is literally the statement you use to change the definition of a tablespace. That's it, that's the whole job description. ✨

Now the important part β€” the permissions vibe check: you must own the tablespace to change its definition. And if you're changing the owner, you also have to be able to SET ROLE to the new owning role. (Also, note that superusers have these privileges automatically β€” main character energy, they don't have to ask. πŸ‘‘)

fr fr, don't try to alter a tablespace you don't own. It's giving "trespassing" and the server will not be nice about it. 😭

πŸŽ€ PARAMETERS πŸŽ€

  • name β€” the name of an existing tablespace. That's the one you're about to alter, bestie.
  • new_name β€” the new name of the tablespace. Massive caveat: the new name cannot begin with pg_, because those names are reserved for system tablespaces. Like, respect the reserved parking spots. 🚫
  • new_owner β€” the new owner of the tablespace. Handing over the crown. πŸ‘‘
  • tablespace_option β€” a tablespace parameter to be set or reset. Hiii, so right now the only available parameters are seq_page_cost, random_page_cost, effective_io_concurrency and maintenance_io_concurrency. When you set these values for a particular tablespace, they override the planner's usual estimate of the cost of reading pages from tables in that tablespace, and the executor's prefetching behavior β€” both of which are normally established by the configuration parameters of the same name (peep 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. πŸš€πŸ’ lowkey one of the most underrated tuning tricks, iykyk.

🌸 EXAMPLES 🌸

Rename tablespace index_space to fast_raid β€” rebranding era:

ALTER TABLESPACE index_space RENAME TO fast_raid;

Change the owner of tablespace index_space β€” here's to new management:

ALTER TABLESPACE index_space OWNER TO mary;

🌈 COMPATIBILITY 🌈

Not to be dramatic, but there is no ALTER TABLESPACE statement in the SQL standard. So this is a PostgreSQL-only moment. πŸ’€


🫢 SEE ALSO 🫢


πŸŽ€ okay that's the whole page bestie, go forth and alter responsibly πŸŽ€

PostgreSQL 16.15, dated 2026 β€” mwah, love u, bye! πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from