ALTER_TABLESPACE(7pg18)

๐Ÿ“ฆ version 18.6, in opensuse-leap 16.0

๐Ÿ’… ALTER_TABLESPACE โ€” change the definition of a tablespace

okay bestie, so this is ALTER_TABLESPACE, from the PostgreSQL 18.6 Documentation era, section 7 of the manual. it's giving "let me redecorate my storage" and honestly? iconic. let's get into it ๐ŸŽ€


โœจ 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 those four little forms. four ways to glow up a tablespace. no cap. ๐ŸŒˆ


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

ALTER TABLESPACE is literally the command you use to change the definition of a tablespace. that's the whole vibe.

but listen โ€” there's a rule, and it's not optional. you must own the tablespace to change its definition. and if you're trying to change the owner? you also need to be able to SET ROLE to the new owning role. (also, small flex: superusers have these privileges automatically, no questions asked ๐Ÿ‘‘)


๐ŸŽ€ PARAMETERS ๐ŸŽ€

  • name โ€” the name of an existing tablespace. it has to actually exist, bestie, we can't rename a vibe that isn't there ๐Ÿ™ˆ
  • new_name โ€” the new name you're giving the tablespace. important: it can't begin with pg_, because names starting with pg_ are reserved for system tablespaces. that prefix is taken, it's their thing, don't touch it ๐Ÿ’€
  • new_owner โ€” the new owner of the tablespace. handing 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 one specific tablespace overrides the planner's usual estimate of the cost of reading pages from tables in that tablespace, and overrides how many concurrent I/Os get issued โ€” the stuff that would normally be established by the configuration parameters of the same name (peep seq_page_cost, random_page_cost, effective_io_concurrency, maintenance_io_concurrency). this is lowkey useful when one tablespace lives on a disk that's faster or slower than the rest of the I/O subsystem. like, one disk is a sports car and the others are a bicycle, you know? ๐Ÿš—๐Ÿ’จ

๐ŸŒธ 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;

see how clean that is? ate and left no crumbs ๐Ÿ’…


๐Ÿ’€ COMPATIBILITY ๐Ÿ’€

there is no ALTER TABLESPACE statement in the SQL standard. it's not a thing there. periodt.


๐ŸŒŸ SEE ALSO ๐ŸŒŸ

  • CREATE TABLESPACE (CREATE_TABLESPACE(7))
  • DROP TABLESPACE (DROP_TABLESPACE(7))

and that's the whole page, bestie ๐Ÿซถ this was PostgreSQL 18.6, dated 2026, and yes โ€” ALTER TABLESPACE(7) really is the moment. go forth and rename responsibly โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from